P1: M3 - Parallelized Parser Formula Interpreter (Archived)

Some doubts

var x = 10;
var x = 5;
line 3: x has already been declared

var x = 10;
line 1: x is not free

var x = 10;
output(string(x + 2));
x + 3;
sqrt(3 + 4);
line 3: invalid expression

Please clarify: Right-to-left or left-to-right?

Rama said "right to left" as the default operator order. Did he really mean "left to right"? Right-to-left is terribly non-standard and unintuitive, but if that's the spec, then that's the spec. For example consider:15 + 15 / 3l-t-r = 10r-t-l = 20

Negative numbers disallowed?

Without the unary operator one cannot enter negative numbers without introducing additional complexity in the lexer/parser. For example: var m1 = -1;The "-1" can be thought of as a negative constant, but if the lexer assumes that, so you get problems with: var m2 = 2-1;Which would be lexed as number(2) number(-1) and a syntax error, as opposed to the correct number(2) operator(-) number(1).Can we conclude that there are therefore no negative numeric constants?

right to left vs unary op

Deep in another thread you stated in lack of parenthesis assume right to left evaluation

a = -1 + 2 + 3;

Right to left evaluation is equivalent to -(1 + (2 + 3)) = -6
as opposed to (-1) + (2 + 3) = 4

then there is

a = 1 + -2 + 3; ? -4 or 2 ?

IMHO unary operators +and - have to be specified (presumably with higher precedence than arithmetic operators)

Jim Dempsey

Ranking query

Assume you have a very long input file with no syntax errors.

It is clear for this case that the time to completion is what is important.

Assume you have a very long input file with no syntax errors except at the very end of the file. (syntax test program).

What is more important? Time to completion with error message or correctly identifying line and statement in program?

Note, these require different strategies for different requirements.

Syntax redux

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.
Suscribirse a P1: M3 - Parallelized Parser Formula Interpreter (Archived)