diff options
| -rw-r--r-- | JPratt/.gitignore | 1 | ||||
| -rw-r--r-- | JPratt/input.txt | 1 | ||||
| -rw-r--r-- | JPratt/src/examples/java/bjc/pratt/examples/PrattParserTest.java | 9 |
3 files changed, 9 insertions, 2 deletions
diff --git a/JPratt/.gitignore b/JPratt/.gitignore index 09e3bc9..3f4e69e 100644 --- a/JPratt/.gitignore +++ b/JPratt/.gitignore @@ -1,2 +1,3 @@ /bin/ /target/ +HTML/ diff --git a/JPratt/input.txt b/JPratt/input.txt new file mode 100644 index 0000000..f51ea5e --- /dev/null +++ b/JPratt/input.txt @@ -0,0 +1 @@ +x := -b ± (sqrt b^2 - 4*a*c) / 2*a diff --git a/JPratt/src/examples/java/bjc/pratt/examples/PrattParserTest.java b/JPratt/src/examples/java/bjc/pratt/examples/PrattParserTest.java index afb3e40..7e94326 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/PrattParserTest.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/PrattParserTest.java @@ -46,7 +46,9 @@ public class PrattParserTest { */ Set<String> ops = new LinkedHashSet<>(); - ops.addAll(Arrays.asList("->")); + ops.add("!!!"); + + ops.addAll(Arrays.asList("->", "=>")); ops.add(":="); ops.addAll(Arrays.asList("||", "&&")); ops.addAll(Arrays.asList("<=", ">=")); @@ -73,7 +75,7 @@ public class PrattParserTest { TwoLevelSplitter split = new TwoLevelSplitter(); - split.addCompoundDelim("->"); + split.addCompoundDelim("->", "=>"); split.addCompoundDelim(":="); split.addCompoundDelim("||", "&&"); split.addCompoundDelim("<=", ">="); @@ -84,6 +86,7 @@ public class PrattParserTest { split.addSimpleDelim("+", "-", "*", "/"); split.addSimpleDelim("^", "!"); + split.addSimpleMulti("!"); split.addSimpleMulti("\\(", "\\)"); split.addSimpleMulti("\\[", "\\]"); split.addSimpleMulti("\\{", "\\}"); @@ -186,6 +189,8 @@ public class PrattParserTest { PrattParser<String, String, TestContext> parser = new PrattParser<>(); + parser.addNonInitialCommand("!!!", postfix(0)); + parser.addNonInitialCommand(":", infixNon(3)); parser.addNonInitialCommand("if", ternary(5, 0, "else", litToken("cond"), false)); |
