Class StructuredGrammarParser
- java.lang.Object
-
- com.singularsys.extensions.structure.StructuredGrammarParser
-
- All Implemented Interfaces:
GrammarParser,java.io.Serializable
public class StructuredGrammarParser extends java.lang.Object implements java.io.Serializable, GrammarParser
A grammar parser which works with structured programming.- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Lookahead2Iterator<Token>it
-
Constructor Summary
Constructors Constructor Description StructuredGrammarParser(GrammaticalRuleI head, GrammarParser sy)Construct the parser
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Nodeparse(java.util.Iterator<Token> input)Main entry point used by the ConfigurableParserNodeparsePrefixSuffix()Callback function used by GrammerMatchers where the matcher expects a simple number, variable, or function call with optional, prefix or suffix operator.NodeparseSubExpression()Calls the parseSubExpression method of the ShuntingYardvoidsetIterator(Lookahead2Iterator<Token> it)Set the iterator used by theGrammarParser.parseSubExpression()
-
-
-
Field Detail
-
it
protected transient Lookahead2Iterator<Token> it
-
-
Constructor Detail
-
StructuredGrammarParser
public StructuredGrammarParser(GrammaticalRuleI head, GrammarParser sy)
Construct the parser- Parameters:
head- root of the rules for parsing the structured grammarsy- base parser for expressions
-
-
Method Detail
-
parse
public Node parse(java.util.Iterator<Token> input) throws ParseException
Description copied from interface:GrammarParserMain entry point used by the ConfigurableParser- Specified by:
parsein interfaceGrammarParser- Parameters:
input- iterator with the list of tokens- Returns:
- the generated parser tree
- Throws:
ParseException- if the input cannot be parsed
-
setIterator
public void setIterator(Lookahead2Iterator<Token> it)
Description copied from interface:GrammarParserSet the iterator used by theGrammarParser.parseSubExpression()- Specified by:
setIteratorin interfaceGrammarParser- Parameters:
it- the iterator
-
parseSubExpression
public Node parseSubExpression() throws ParseException
Calls the parseSubExpression method of the ShuntingYard- Specified by:
parseSubExpressionin interfaceGrammarParser- Returns:
- the root node of the matched sub expression.
- Throws:
ParseException- if the input cannot be parsed
-
parsePrefixSuffix
public Node parsePrefixSuffix() throws ParseException
Description copied from interface:GrammarParserCallback function used by GrammerMatchers where the matcher expects a simple number, variable, or function call with optional, prefix or suffix operator.- Specified by:
parsePrefixSuffixin interfaceGrammarParser- Returns:
- the root node of the matched sub expression.
- Throws:
ParseException- if the input cannot be parsed
-
-