diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-11 21:57:37 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-11 21:57:37 -0400 |
| commit | 3f74e1e25fd572adab34e53eb90edcf49404fbe5 (patch) | |
| tree | 1a960016d2e58414f91fb1e43348c29c2ab6db20 | |
| parent | 7a510ceb37780a7d0da37117a5cfce23c2919257 (diff) | |
Cleanup
12 files changed, 82 insertions, 76 deletions
diff --git a/JPratt/src/examples/java/bjc/pratt/examples/AssignCommand.java b/JPratt/src/examples/java/bjc/pratt/examples/lang/AssignCommand.java index f3cc003..5053f67 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/AssignCommand.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/lang/AssignCommand.java @@ -1,4 +1,4 @@ -package bjc.pratt.examples; +package bjc.pratt.examples.lang; import bjc.pratt.ParserContext; import bjc.pratt.Token; diff --git a/JPratt/src/examples/java/bjc/pratt/examples/BlockEnter.java b/JPratt/src/examples/java/bjc/pratt/examples/lang/BlockEnter.java index 092c6b2..41e0303 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/BlockEnter.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/lang/BlockEnter.java @@ -1,4 +1,4 @@ -package bjc.pratt.examples; +package bjc.pratt.examples.lang; import java.util.function.UnaryOperator; diff --git a/JPratt/src/examples/java/bjc/pratt/examples/BlockExit.java b/JPratt/src/examples/java/bjc/pratt/examples/lang/BlockExit.java index ea9526d..15b2a5e 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/BlockExit.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/lang/BlockExit.java @@ -1,4 +1,4 @@ -package bjc.pratt.examples; +package bjc.pratt.examples.lang; import java.util.function.UnaryOperator; diff --git a/JPratt/src/examples/java/bjc/pratt/examples/PrattParserTest.java b/JPratt/src/examples/java/bjc/pratt/examples/lang/PrattParserTest.java index 7b9feea..20450a1 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/PrattParserTest.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/lang/PrattParserTest.java @@ -1,4 +1,4 @@ -package bjc.pratt.examples; +package bjc.pratt.examples.lang; import static bjc.pratt.commands.InitialCommands.delimited; import static bjc.pratt.commands.InitialCommands.grouping; @@ -34,10 +34,10 @@ import bjc.pratt.tokens.StringTokenStream; import bjc.utils.data.ITree; import bjc.utils.data.TransformIterator; import bjc.utils.parserutils.ParserException; -import bjc.utils.parserutils.splitterv2.ChainTokenSplitter; -import bjc.utils.parserutils.splitterv2.ConfigurableTokenSplitter; -import bjc.utils.parserutils.splitterv2.ExcludingTokenSplitter; -import bjc.utils.parserutils.splitterv2.TokenSplitter; +import bjc.utils.parserutils.splitter.ChainTokenSplitter; +import bjc.utils.parserutils.splitter.ConfigurableTokenSplitter; +import bjc.utils.parserutils.splitter.ExcludingTokenSplitter; +import bjc.utils.parserutils.splitter.TokenSplitter; /** * Simple test for Pratt parser. diff --git a/JPratt/src/examples/java/bjc/pratt/examples/SwitchCommand.java b/JPratt/src/examples/java/bjc/pratt/examples/lang/SwitchCommand.java index 6c4e2b6..f5fc9b1 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/SwitchCommand.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/lang/SwitchCommand.java @@ -1,4 +1,4 @@ -package bjc.pratt.examples; +package bjc.pratt.examples.lang; import bjc.pratt.InitialCommand; import bjc.pratt.ParserContext; diff --git a/JPratt/src/examples/java/bjc/pratt/examples/TestContext.java b/JPratt/src/examples/java/bjc/pratt/examples/lang/TestContext.java index e5583b4..659ba36 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/TestContext.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/lang/TestContext.java @@ -1,4 +1,4 @@ -package bjc.pratt.examples; +package bjc.pratt.examples.lang; import bjc.pratt.Token; import bjc.utils.data.ITree; diff --git a/JPratt/src/examples/java/bjc/pratt/examples/Tokenizer.java b/JPratt/src/examples/java/bjc/pratt/examples/lang/Tokenizer.java index 4f8da12..ea162be 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/Tokenizer.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/lang/Tokenizer.java @@ -1,4 +1,4 @@ -package bjc.pratt.examples; +package bjc.pratt.examples.lang; import static bjc.pratt.tokens.StringToken.litToken; @@ -23,16 +23,24 @@ final class Tokenizer implements Function<String, Token<String, String>> { @Override public Token<String, String> apply(final String strang) { - if (ops.contains(strang) || reserved.contains(strang)) { + if (ops.contains(strang) || reserved.contains(strang)) return litToken(strang); - } else if (strang.matches("(?:[\\u00B2\\u00B3\\u00B9\\u2070]|[\\u2074-\\u2079])+")) { - /* - * This regular expression matches series of unicode - * super - scripts 1 - 9. - */ + else if (strang.matches("(?:[\\u00B2\\u00B3\\u00B9\\u2070]|[\\u2074-\\u2079])+")) /* + * This + * regular + * expression + * matches + * series + * of + * unicode + * super + * - + * scripts + * 1 + * - + * 9. + */ return new StringToken("(superexp)", strang); - } else { - return new StringToken("(literal)", strang); - } + else return new StringToken("(literal)", strang); } } diff --git a/JPratt/src/examples/java/bjc/pratt/examples/VarCommand.java b/JPratt/src/examples/java/bjc/pratt/examples/lang/VarCommand.java index a194b72..a2f428b 100644 --- a/JPratt/src/examples/java/bjc/pratt/examples/VarCommand.java +++ b/JPratt/src/examples/java/bjc/pratt/examples/lang/VarCommand.java @@ -1,4 +1,4 @@ -package bjc.pratt.examples; +package bjc.pratt.examples.lang; import bjc.pratt.ParserContext; import bjc.pratt.Token; diff --git a/JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java index 459f83d..b714940 100644 --- a/JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java +++ b/JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java @@ -13,40 +13,40 @@ import bjc.utils.parserutils.ParserException; /** * A {@link ParseBlock} that parses an expression from a 'inner' grammar. - * + * * @author bjculkin * * @param <K> * The key type of the outer tokens. - * + * * @param <V> * The value type of the outer tokens. - * + * * @param <C> * The state type of the outer parser. - * + * * @param <K2> * The key type of the inner tokens. - * + * * @param <V2> * The value type of the inner tokens. - * + * * @param <C2> * The state type of the outer parser. */ public class GrammarParseBlock<K, V, C, K2, V2, C2> implements ParseBlock<K, V, C> { - private PrattParser<K2, V2, C2> inner; + private final PrattParser<K2, V2, C2> innr; - private int precedence; - private boolean isStatement; + private final int prcedence; + private final boolean isStatemnt; - private Function<TokenStream<K, V>, TokenStream<K2, V2>> tokenTransform; - private Isomorphism<C, C2> stateTransform; - private Function<ITree<Token<K2, V2>>, ITree<Token<K, V>>> expressionTransform; + private final Function<TokenStream<K, V>, TokenStream<K2, V2>> tkenTransform; + private final Isomorphism<C, C2> stteTransform; + private final Function<ITree<Token<K2, V2>>, ITree<Token<K, V>>> xpressionTransform; /** * Create a new grammar parser block. - * + * * @param inner * @param precedence * @param isStatement @@ -54,28 +54,29 @@ public class GrammarParseBlock<K, V, C, K2, V2, C2> implements ParseBlock<K, V, * @param stateTransform * @param expressionTransform */ - public GrammarParseBlock(PrattParser<K2, V2, C2> inner, int precedence, boolean isStatement, - Function<TokenStream<K, V>, TokenStream<K2, V2>> tokenTransform, - Isomorphism<C, C2> stateTransform, - Function<ITree<Token<K2, V2>>, ITree<Token<K, V>>> expressionTransform) { - this.inner = inner; - this.precedence = precedence; - this.isStatement = isStatement; - this.tokenTransform = tokenTransform; - this.stateTransform = stateTransform; - this.expressionTransform = expressionTransform; + public GrammarParseBlock(final PrattParser<K2, V2, C2> inner, final int precedence, final boolean isStatement, + final Function<TokenStream<K, V>, TokenStream<K2, V2>> tokenTransform, + final Isomorphism<C, C2> stateTransform, + final Function<ITree<Token<K2, V2>>, ITree<Token<K, V>>> expressionTransform) { + innr = inner; + prcedence = precedence; + isStatemnt = isStatement; + tkenTransform = tokenTransform; + stteTransform = stateTransform; + xpressionTransform = expressionTransform; } @Override - public ITree<Token<K, V>> parse(ParserContext<K, V, C> ctx) throws ParserException { - C2 newState = stateTransform.to(ctx.state); + public ITree<Token<K, V>> parse(final ParserContext<K, V, C> ctx) throws ParserException { + final C2 newState = stteTransform.to(ctx.state); - TokenStream<K2, V2> newTokens = tokenTransform.apply(ctx.tokens); + final TokenStream<K2, V2> newTokens = tkenTransform.apply(ctx.tokens); - ITree<Token<K2, V2>> expression = inner.parseExpression(precedence, newTokens, newState, isStatement); + final ITree<Token<K2, V2>> expression = innr.parseExpression(prcedence, newTokens, newState, + isStatemnt); - ctx.state = stateTransform.from(newState); + ctx.state = stteTransform.from(newState); - return expressionTransform.apply(expression); + return xpressionTransform.apply(expression); } }
\ No newline at end of file diff --git a/JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java b/JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java index a3e3147..44288d2 100644 --- a/JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java +++ b/JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java @@ -1,15 +1,11 @@ package bjc.pratt.blocks; -import java.util.function.Function; import java.util.function.Predicate; import java.util.function.UnaryOperator; import bjc.pratt.ParseBlock; -import bjc.pratt.PrattParser; import bjc.pratt.Token; -import bjc.pratt.TokenStream; import bjc.utils.data.ITree; -import bjc.utils.funcutils.Isomorphism; /** * Utility class for creating common implementations of {@link ParseBlock} diff --git a/JPratt/src/main/java/bjc/pratt/commands/BlockInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/BlockInitialCommand.java index f0448f7..ca2d31a 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/BlockInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/BlockInitialCommand.java @@ -8,33 +8,33 @@ import bjc.utils.parserutils.ParserException; /** * An initial command that delegates all the work to a {@link ParseBlock} - * + * * @author bjculkin * @param <K> * The token key type. - * + * * @param <V> * The token value type. - * + * * @param <C> * The parser state type. * */ public class BlockInitialCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { - private ParseBlock<K, V, C> blck; + private final ParseBlock<K, V, C> blck; /** * Create a new block initial command. - * + * * @param block * The block to delegate to. */ - public BlockInitialCommand(ParseBlock<K, V, C> block) { + public BlockInitialCommand(final ParseBlock<K, V, C> block) { blck = block; } @Override - protected ITree<Token<K, V>> intNullDenotation(Token<K, V> operator, ParserContext<K, V, C> ctx) + protected ITree<Token<K, V>> intNullDenotation(final Token<K, V> operator, final ParserContext<K, V, C> ctx) throws ParserException { return blck.parse(ctx); } diff --git a/JPratt/src/main/java/bjc/pratt/commands/BlockNonInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/BlockNonInitialCommand.java index 9a5ffc9..c361c73 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/BlockNonInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/BlockNonInitialCommand.java @@ -10,42 +10,43 @@ import bjc.utils.parserutils.ParserException; /** * A non-initial command that delegates all of the work to a {@link ParseBlock} - * + * * @author bjculkin * * @param <K> * The token key type. - * + * * @param <V> * The token value type. - * + * * @param <C> * The parser state type. */ public class BlockNonInitialCommand<K, V, C> extends NonInitialCommand<K, V, C> { - private ParseBlock<K, V, C> innr; + private final ParseBlock<K, V, C> innr; - private int lftBind; - private int nxtBind; + private final int lftBind; + private final int nxtBind; - private Token<K, V> trm; + private final Token<K, V> trm; /** * Create a new non-initial command that delegates to a parse block. - * + * * @param inner * The parse block to delegate to. - * + * * @param leftBind * The left binding power (precedence). - * + * * @param rightBind * The right binding power (associativity control). - * + * * @param term * The token to use as the node in the AST. */ - public BlockNonInitialCommand(ParseBlock<K, V, C> inner, int leftBind, int rightBind, Token<K, V> term) { + public BlockNonInitialCommand(final ParseBlock<K, V, C> inner, final int leftBind, final int rightBind, + final Token<K, V> term) { innr = inner; lftBind = leftBind; @@ -55,9 +56,9 @@ public class BlockNonInitialCommand<K, V, C> extends NonInitialCommand<K, V, C> } @Override - public ITree<Token<K, V>> denote(ITree<Token<K, V>> operand, Token<K, V> operator, ParserContext<K, V, C> ctx) - throws ParserException { - ITree<Token<K, V>> expression = innr.parse(ctx); + public ITree<Token<K, V>> denote(final ITree<Token<K, V>> operand, final Token<K, V> operator, + final ParserContext<K, V, C> ctx) throws ParserException { + final ITree<Token<K, V>> expression = innr.parse(ctx); return new Tree<>(trm, expression); } |
