diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-25 19:13:42 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-25 19:13:42 -0400 |
| commit | 42990231fee502552b769b9af4c04ac0dcaeb195 (patch) | |
| tree | 4dbe0ba0bc54fffafacc9ab12349efd76c52041c /BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/DelimitedCommand.java | |
| parent | 674d9769821775484fe6913b93c650189fbedfed (diff) | |
Update Pratt parser
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/DelimitedCommand.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/DelimitedCommand.java | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/DelimitedCommand.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/DelimitedCommand.java deleted file mode 100644 index 090b2f4..0000000 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/DelimitedCommand.java +++ /dev/null @@ -1,65 +0,0 @@ -package bjc.utils.parserutils.pratt.commands; - -import bjc.utils.data.ITree; -import bjc.utils.data.Tree; -import bjc.utils.funcdata.FunctionalList; -import bjc.utils.funcdata.IList; -import bjc.utils.parserutils.ParserException; -import bjc.utils.parserutils.pratt.ParserContext; -import bjc.utils.parserutils.pratt.Token; - -import java.util.function.UnaryOperator; - -public class DelimitedCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { - private int inner; - - private K delim; - private K mark; - - private Token<K, V> term; - - private UnaryOperator<C> onEnter; - private UnaryOperator<C> onDelim; - private UnaryOperator<C> onExit; - - private boolean statement; - - public DelimitedCommand(int inner, K delim, K mark, Token<K, V> term, UnaryOperator<C> onEnter, - UnaryOperator<C> onDelim, UnaryOperator<C> onExit, boolean statement) { - this.inner = inner; - this.delim = delim; - this.mark = mark; - this.term = term; - this.onEnter = onEnter; - this.onDelim = onDelim; - this.onExit = onExit; - this.statement = statement; - } - - @SuppressWarnings("unchecked") - @Override - protected ITree<Token<K, V>> intNullDenotation(Token<K, V> operator, ParserContext<K, V, C> ctx) - throws ParserException { - C newState = onEnter.apply(ctx.state); - - IList<ITree<Token<K, V>>> kids = new FunctionalList<>(); - - while(true) { - ITree<Token<K, V>> kid = ctx.parse.parseExpression(inner, ctx.tokens, newState, - statement); - kids.add(kid); - - Token<K, V> tok = ctx.tokens.current(); - - ctx.tokens.expect(delim, mark); - - if(tok.getKey().equals(mark)) break; - - newState = onDelim.apply(newState); - } - - ctx.state = onExit.apply(newState); - - return new Tree<>(term, kids); - } -}
\ No newline at end of file |
