diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-24 18:28:34 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-24 18:28:34 -0400 |
| commit | 42a897dae1bfa58ab665f5012c2ac160316bcb75 (patch) | |
| tree | 0cf3ec5c7958c63672f6657b93e4cb1536b2d4a3 /BJC-Utils2/src/main/java/bjc | |
| parent | 0f6565687e03968abd2e508fa8183f50f04f1cc7 (diff) | |
Update Pratt Parser
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc')
3 files changed, 73 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/InitialInterleaveCommand.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/InitialInterleaveCommand.java new file mode 100644 index 0000000..554cf30 --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/InitialInterleaveCommand.java @@ -0,0 +1,29 @@ +package bjc.utils.parserutils.pratt.commands; + +import bjc.utils.data.ITree; +import bjc.utils.parserutils.ParserException; +import bjc.utils.parserutils.pratt.ParserContext; +import bjc.utils.parserutils.pratt.Token; + +/** + * Represents a configurable initial command. + * + * @author EVE + * + * @param <K> + * The token key type. + * + * @param <V> + * The token value type. + * + * @param <C> + * The parser state type. + */ +public class InitialInterleaveCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { + @Override + protected ITree<Token<K, V>> intNullDenotation(Token<K, V> operator, ParserContext<K, V, C> ctx) + throws ParserException { + return null; + } + +} diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/InterleaveSpecifier.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/InterleaveSpecifier.java new file mode 100644 index 0000000..fa2c592 --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/InterleaveSpecifier.java @@ -0,0 +1,30 @@ +package bjc.utils.parserutils.pratt.commands; + +/** + * The specifier for what to do for each element of a command. + * + * @author EVE + * + */ +public class InterleaveSpecifier { + /** + * The type of this specifier. + * + * @author EVE + * + */ + public static enum Type { + /** + * Parse an expression with the given priority. + */ + EXPRESSION, + /** + * Parse a statement with the given priority. + */ + STATEMENT, + /** + * Expect a token of a certain type to be present. + */ + EXPECT, LITERAL; + } +}
\ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/splitter/TwoLevelSplitter.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/splitter/TwoLevelSplitter.java index 38f303d..d65b06a 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/splitter/TwoLevelSplitter.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/splitter/TwoLevelSplitter.java @@ -100,6 +100,20 @@ public class TwoLevelSplitter implements TokenSplitter { } /** + * Exclude strings matching a regex from both splits. + * + * @param exclusions + * The regexes to exclude matches for. + */ + public void exclude(String... exclusions) { + for(String exclusion : exclusions) { + high.addNonMatcher(exclusion); + + low.addNonMatcher(exclusion); + } + } + + /** * Ready the splitter for use. */ public void compile() { |
