From ee8ab3464bdfe423c8b09b3f9a403899127f1078 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 6 Apr 2017 05:46:27 -0400 Subject: Add unicode superscripts --- JPratt/.gitignore | 1 + JPratt/input.txt | 1 + JPratt/src/examples/java/bjc/pratt/examples/PrattParserTest.java | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 JPratt/input.txt 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 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 parser = new PrattParser<>(); + parser.addNonInitialCommand("!!!", postfix(0)); + parser.addNonInitialCommand(":", infixNon(3)); parser.addNonInitialCommand("if", ternary(5, 0, "else", litToken("cond"), false)); -- cgit v1.2.3