diff options
| author | Ben Culkin <scorpress@gmail.com> | 2022-08-16 23:03:27 -0400 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2022-08-16 23:03:27 -0400 |
| commit | cea3e47938322b97c318dea38dc0d649e196dc1b (patch) | |
| tree | 0ceef0bafbfed7aa5802e8fc526c0c98276f1fff /JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java | |
| parent | 4869146748ed51eb212935d2b971388fb9e73d37 (diff) | |
Refactor to add backtracking support
This probably doesn't help w/ error messages, but it enables some cool
ideas where syntax can be reused in cases where it would otherwise be
invalid
Diffstat (limited to 'JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java')
| -rw-r--r-- | JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java b/JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java index 0cfec29..9801788 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java @@ -9,6 +9,7 @@ import java.util.function.UnaryOperator; import bjc.pratt.blocks.ParseBlock; import bjc.pratt.commands.InitialCommand; import bjc.pratt.tokens.Token; +import bjc.utils.parserutils.ParserException; import bjc.data.SimpleTree; import bjc.data.Tree; @@ -210,16 +211,6 @@ public class InitialCommands { * @return A command that implements a panfix operator */ public static <K, V, C> InitialCommand<K, V, C> panfix(final int precedence, final K term, final Token<K, V> marker) { - return (operator, ctx) -> { - Tree<Token<K,V>> leftSide = ctx.parse.parseExpression(precedence + 1, ctx.tokens, ctx.state, false); - ctx.tokens.expect(term); - ctx.tokens.next(); - - Tree<Token<K,V>> rightSide = ctx.parse.parseExpression(precedence + 1, ctx.tokens, ctx.state, false); - ctx.tokens.expect(term); - ctx.tokens.next(); - - return new SimpleTree<>(marker, leftSide, rightSide); - }; + return new PanfixCommand<K, V, C>(marker, term, precedence); } }
\ No newline at end of file |
