Expression in op def gives spurious syntax error
Posted: Fri Dec 28, 2012 5:28 pm
A certain UPDATE command works fine in DBrowser. When I parameterise it in an operator definition, such that literals are replaced by parameter names, I get an error message that seems to be spurious. I found that enclosing the WHERE condition in parens fixed the problem. Below is an example, copied-and-pasted from DBrowser's output panel. Relvar rv is declared and an update command is given successfully. Then comes the operator definition that is rejected, followed by the revised operator definition that works.
Hugh Darwen
var rv base init(rel{tup{x 1, y 'a'}}) key{x} ;
Ok.
update rv where x = 1 ( y := 'b' );
NOTICE: Updated 1 tuple.
Ok.
operator sety (xp integer, yp char); update rv where x = xp ( y := yp ); end operator;
ERROR: Encountered ":=" at line 1, column 65.
Was expecting one of: "AND" ... "COMPOSE" ... "DIVIDEBY" ... "D_UNION" ... "GROUP" ... "IN" ... "INTERSECT" ... "JOIN" ... "MATCHING" ... "MINUS" ... "NOT" ... "ORDER" ... "OR" ... "RENAME" ... "SEMIJOIN" ... "SEMIMINUS" ... "UNGROUP" ... "UNION" ... "UNWRAP" ... "WHERE" ... "WRAP" ... "XOR" ... ")" ... "{" ... "," ... "=" ... ">" ... "<" ... "<=" ... ">=" ... "<>" ... "+" ... "-" ... "*" ... "/" ... "[" ... "||" ... "*" ... "/" ... "+" ... "-" ... "||" ... "{" ... "RENAME" ... "WRAP" ... "UNWRAP" ... "GROUP" ... "UNGROUP" ... "DIVIDEBY" ... "UNION" ... "D_UNION" ... "INTERSECT" ... "MINUS" ... "JOIN" ... "COMPOSE" ... "SEMIJOIN" ... "MATCHING" ... "SEMIMINUS" ... "NOT" ... "=" ... "<>" ... ">=" ... "<=" ... ">" ... "<" ... "IN" ... "AND" ... "XOR" ... "OR" ... "WHERE" ... "ORDER" ... "[" ... "[" ...
operator sety (xp integer, yp char); update rv where (x = xp) ( y := yp ); end operator;
Ok.
Hugh Darwen
var rv base init(rel{tup{x 1, y 'a'}}) key{x} ;
Ok.
update rv where x = 1 ( y := 'b' );
NOTICE: Updated 1 tuple.
Ok.
operator sety (xp integer, yp char); update rv where x = xp ( y := yp ); end operator;
ERROR: Encountered ":=" at line 1, column 65.
Was expecting one of: "AND" ... "COMPOSE" ... "DIVIDEBY" ... "D_UNION" ... "GROUP" ... "IN" ... "INTERSECT" ... "JOIN" ... "MATCHING" ... "MINUS" ... "NOT" ... "ORDER" ... "OR" ... "RENAME" ... "SEMIJOIN" ... "SEMIMINUS" ... "UNGROUP" ... "UNION" ... "UNWRAP" ... "WHERE" ... "WRAP" ... "XOR" ... ")" ... "{" ... "," ... "=" ... ">" ... "<" ... "<=" ... ">=" ... "<>" ... "+" ... "-" ... "*" ... "/" ... "[" ... "||" ... "*" ... "/" ... "+" ... "-" ... "||" ... "{" ... "RENAME" ... "WRAP" ... "UNWRAP" ... "GROUP" ... "UNGROUP" ... "DIVIDEBY" ... "UNION" ... "D_UNION" ... "INTERSECT" ... "MINUS" ... "JOIN" ... "COMPOSE" ... "SEMIJOIN" ... "MATCHING" ... "SEMIMINUS" ... "NOT" ... "=" ... "<>" ... ">=" ... "<=" ... ">" ... "<" ... "IN" ... "AND" ... "XOR" ... "OR" ... "WHERE" ... "ORDER" ... "[" ... "[" ...
operator sety (xp integer, yp char); update rv where (x = xp) ( y := yp ); end operator;
Ok.