Class Parser
- java.lang.Object
- 
- com.inductiveautomation.snap.parse.Parser
 
- 
- Direct Known Subclasses:
- JavaParser,- ParseUtils.DebugParser
 
 public class Parser extends java.lang.ObjectA class to parse a given input (string) using given rule(s).
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ParseNodecreateNode(ParseRule aRule, Token aStartToken, Token anEndToken)Creates a node for given rule and start/end tokens (returns a shared node by default).protected ParseRulecreateRule()Creates the top level rule.protected TokenizercreateTokenizer()Creates the tokenizer instance and initializes patters from rule.protected TokenizercreateTokenizerImpl()Creates the tokenizer instance.java.lang.CharSequencegetInput()Returns the current parse character input.protected TokengetLookAheadToken(int anIndex)Returns the look ahead token at given index.protected TokengetNextToken()Fetches and returns the next token.ParseRulegetRule()Returns the top level rule.TokengetToken()Returns the current token.TokenizergetTokenizer()Returns the tokenizer.protected intlookAhead(ParseRule aRule, int aLookAhead, int aTokenIndex, int aPathIndex, int aRuleIndex)Returns a parse node if this rule matches string.ParseNodeparse()Parses input and returns ParseNode.protected ParseNodeparse(ParseRule aRule, ParseHandler aHandler)Returns a parse node if this rule matches string.ParseNodeparse(java.lang.CharSequence anInput)Parses a given input and returns ParseNode (convenience).<T> TparseCustom(java.lang.CharSequence anInput, java.lang.Class<T> aClass)Parses given input and returns custom parse tree node (convenience).<T> TparseCustom(java.lang.Class<T> aClass)Parses input and returns custom parse tree node.protected voidparseFailed(ParseRule aRule, ParseHandler aHandler, ParseRule.Count aCount)Called when parse fails.ParsersetInput(java.lang.CharSequence aSequence)Sets the current parse string.voidsetRule(ParseRule aRule)Sets the top level rule.protected voidsetTokenizer(Tokenizer aTokenizer)Sets the tokenizer.
 
- 
- 
- 
Constructor Detail- 
Parserpublic Parser() Creates a new Parser.
 - 
Parserpublic Parser(ParseRule aRule) Creates a new Parser for given rule.
 
- 
 - 
Method Detail- 
getRulepublic ParseRule getRule() Returns the top level rule.
 - 
setRulepublic void setRule(ParseRule aRule) Sets the top level rule.
 - 
createRuleprotected ParseRule createRule() Creates the top level rule.
 - 
getInputpublic java.lang.CharSequence getInput() Returns the current parse character input.
 - 
setInputpublic Parser setInput(java.lang.CharSequence aSequence) Sets the current parse string.
 - 
getTokenizerpublic Tokenizer getTokenizer() Returns the tokenizer.
 - 
createTokenizerprotected Tokenizer createTokenizer() Creates the tokenizer instance and initializes patters from rule.
 - 
createTokenizerImplprotected Tokenizer createTokenizerImpl() Creates the tokenizer instance.
 - 
setTokenizerprotected void setTokenizer(Tokenizer aTokenizer) Sets the tokenizer.
 - 
getTokenpublic Token getToken() Returns the current token.
 - 
getNextToken@Nonnull protected Token getNextToken() Fetches and returns the next token.
 - 
getLookAheadTokenprotected Token getLookAheadToken(int anIndex) Returns the look ahead token at given index.
 - 
parsepublic ParseNode parse() Parses input and returns ParseNode.
 - 
parseCustompublic <T> T parseCustom(java.lang.Class<T> aClass) Parses input and returns custom parse tree node.
 - 
parseprotected ParseNode parse(ParseRule aRule, ParseHandler aHandler) Returns a parse node if this rule matches string.
 - 
createNodeprotected ParseNode createNode(ParseRule aRule, Token aStartToken, Token anEndToken) Creates a node for given rule and start/end tokens (returns a shared node by default).
 - 
lookAheadprotected int lookAhead(ParseRule aRule, int aLookAhead, int aTokenIndex, int aPathIndex, int aRuleIndex) Returns a parse node if this rule matches string.
 - 
parseFailedprotected void parseFailed(ParseRule aRule, ParseHandler aHandler, ParseRule.Count aCount) Called when parse fails.
 - 
parsepublic ParseNode parse(java.lang.CharSequence anInput) Parses a given input and returns ParseNode (convenience).
 - 
parseCustompublic <T> T parseCustom(java.lang.CharSequence anInput, java.lang.Class<T> aClass)Parses given input and returns custom parse tree node (convenience).
 
- 
 
-