Class Parser
java.lang.Object
com.inductiveautomation.snap.parse.Parser
- Direct Known Subclasses:
JavaParser
,ParseUtils.DebugParser
A class to parse a given input (string) using given rule(s).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ParseNode
createNode
(ParseRule aRule, Token aStartToken, Token anEndToken) Creates a node for given rule and start/end tokens (returns a shared node by default).protected ParseRule
Creates the top level rule.protected Tokenizer
Creates the tokenizer instance and initializes patters from rule.protected Tokenizer
Creates the tokenizer instance.getInput()
Returns the current parse character input.protected Token
getLookAheadToken
(int anIndex) Returns the look ahead token at given index.protected Token
Fetches and returns the next token.getRule()
Returns the top level rule.getToken()
Returns the current token.Returns the tokenizer.protected int
Returns a parse node if this rule matches string.parse()
Parses input and returns ParseNode.protected ParseNode
parse
(ParseRule aRule, ParseHandler aHandler) Returns a parse node if this rule matches string.parse
(CharSequence anInput) Parses a given input and returns ParseNode (convenience).<T> T
parseCustom
(CharSequence anInput, Class<T> aClass) Parses given input and returns custom parse tree node (convenience).<T> T
parseCustom
(Class<T> aClass) Parses input and returns custom parse tree node.protected void
parseFailed
(ParseRule aRule, ParseHandler aHandler, ParseRule.Count aCount) Called when parse fails.setInput
(CharSequence aSequence) Sets the current parse string.void
Sets the top level rule.protected void
setTokenizer
(Tokenizer aTokenizer) Sets the tokenizer.
-
Constructor Details
-
Parser
public Parser()Creates a new Parser. -
Parser
Creates a new Parser for given rule.
-
-
Method Details
-
getRule
Returns the top level rule. -
setRule
Sets the top level rule. -
createRule
Creates the top level rule. -
getInput
Returns the current parse character input. -
setInput
Sets the current parse string. -
getTokenizer
Returns the tokenizer. -
createTokenizer
Creates the tokenizer instance and initializes patters from rule. -
createTokenizerImpl
Creates the tokenizer instance. -
setTokenizer
Sets the tokenizer. -
getToken
Returns the current token. -
getNextToken
Fetches and returns the next token. -
getLookAheadToken
Returns the look ahead token at given index. -
parse
Parses input and returns ParseNode. -
parseCustom
Parses input and returns custom parse tree node. -
parse
Returns a parse node if this rule matches string. -
createNode
Creates a node for given rule and start/end tokens (returns a shared node by default). -
lookAhead
protected int lookAhead(ParseRule aRule, int aLookAhead, int aTokenIndex, int aPathIndex, int aRuleIndex) Returns a parse node if this rule matches string. -
parseFailed
Called when parse fails. -
parse
Parses a given input and returns ParseNode (convenience). -
parseCustom
Parses given input and returns custom parse tree node (convenience).
-