The other thread was getting croweded, so here's a new attempt:Taking comments into account:
- From another thread I believe that only one statement per line is allowed
No, we've confirmed that this is allowed:
var x = 1; var y = 2;
- I think you can get away with this for NumericConstant (depending on if a zero is required before the decimal point or not):NumericConstant = ([0-9]*'.')?[0-9]+
No this does not match "1."
- I've given all operators equal precedence [...]This makes "1 + 2 +3" illegal, but "1 + (2 + 3)" not.
From Rama:I think it would be better to evaluate expression from right-to-left. Hope this clarifies.
- Can identifiers be keywords? I hope not cause its requires extra lookahead:
var sqrt = 1;
var x = sqrt + 1;
From Gaston: Keywords and function names not allowed as variables.
- Because expressions can consist solely of variables (e.g. "A + B") I've made one root expression rule.
- Can () be used to group string expressions? It would never have any effect, but are they allowed syntactically, e.g.:
A + ("foo" + "bar") + string(X)