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 Node
parse(java.util.Iterator<Token> input)
Main entry point used by the ConfigurableParserNode
parsePrefixSuffix()
Callback function used by GrammerMatchers where the matcher expects a simple number, variable, or function call with optional, prefix or suffix operator.Node
parseSubExpression()
Calls the parseSubExpression method of the ShuntingYardvoid
setIterator(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:GrammarParser
Main entry point used by the ConfigurableParser- Specified by:
parse
in 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:GrammarParser
Set the iterator used by theGrammarParser.parseSubExpression()
- Specified by:
setIterator
in interfaceGrammarParser
- Parameters:
it
- the iterator
-
parseSubExpression
public Node parseSubExpression() throws ParseException
Calls the parseSubExpression method of the ShuntingYard- Specified by:
parseSubExpression
in 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:GrammarParser
Callback function used by GrammerMatchers where the matcher expects a simple number, variable, or function call with optional, prefix or suffix operator.- Specified by:
parsePrefixSuffix
in interfaceGrammarParser
- Returns:
- the root node of the matched sub expression.
- Throws:
ParseException
- if the input cannot be parsed
-
-