Never mind, ignore me, I was looking at the wrong branch of elastic-core.
However, I did find some other parser/interp weirdness just now...
First, negative literals can't be specified. So you always need to put "-1" as "(0-1)" which eats up WCET unnecessarily.
Somewhat similarly, it seems that the parser would allow "((m[0] = 0) & (m[1] = 1)) + 1" but not "(m[0] = 0) & (m[1] = 1) + 1"....
Finally, the following program does not interpret as one would expect:
It never assigns m[20] and assigns 1 to m[15].
I have fixed a couple of things in the parser now. I agree that a linear language would be way better, I have started experimenting with ANTLR (which would also be capable of generating parsers for C which might be handy for coralreefer) but I feel it would be better to (at least for now) focus on the design questions regarding the POW retarget ... if the parser is safe now ;-)
Fixes in latest git commit:
- Updated to JavaCC 6.1 RC
- Assignments cannot be used in any nested expressions anymore, the problem was that the assignment statement does not push any value to the stack causing some undeterministic behaviour when used as if it would return a value (like in an assignment itself)
- The stack-depth is not only limited for the calculation stack, but also for the parser stack. Nested blocks (or any other nodes) with a depth > 512 are not allowed and throw a ParseException during parse. This saves us from a real StackOverflowException which could cause the entire java process to crash. Was a bit tricky as JavaCC regenerates the JJParserState on every invocation.
(See the POW example in stack_overflow.spl, which is basically your 100000x nested block worst case example) - fixed a NumberFormatException, that was thrown when an integer literal was provided which was not an integer (e.g., 1523589238529385239)
- unary minus operator
coming soonis now there
I will have your 1 BTC gift ready this evening Thanks for everything!