Added for loops to the expression parser, java style.

Also:
- Added a test case for for
- Fixed Identifiable.id() for the runtime Nodes and added missing elements to the list in Identifiable.java.
- Factored keyword and character consumption into a common function.
This commit is contained in:
TomyLobo
2011-11-22 16:08:15 +01:00
parent f217be0bdf
commit effbf9f79c
7 changed files with 114 additions and 32 deletions

View File

@ -92,6 +92,11 @@ public class ExpressionTest {
assertEquals(5, simpleEval("c=5; a=0; do { ++a; --c; } while (c > 0) a"), 0);
}
@Test
public void testFor() throws ExpressionException {
assertEquals(5, simpleEval("a=0; for (i=0; i<5; ++i) { ++a; } a"), 0);
}
private double simpleEval(String expression) throws ExpressionException {
return Expression.compile(expression).evaluate();
}