Package com.scriptbasic.syntax.commands
Class AbstractCommandAnalyzer
- java.lang.Object
-
- com.scriptbasic.syntax.AbstractAnalyzer<Command>
-
- com.scriptbasic.syntax.commands.AbstractCommandAnalyzer
-
- All Implemented Interfaces:
Analyzer<Command>,CommandAnalyzer
- Direct Known Subclasses:
AbstractCommandAnalyzerGlobalLocal,AbstractCommandAnalyzerIfElseKind,CommandAnalyzerCall,CommandAnalyzerDSL,CommandAnalyzerEndSub,CommandAnalyzerFor,CommandAnalyzerLet,CommandAnalyzerMethod,CommandAnalyzerNext,CommandAnalyzerPrint,CommandAnalyzerReturn,CommandAnalyzerSub,CommandAnalyzerUse,CommandAnalyzerWend,CommandAnalyzerWhile
public abstract class AbstractCommandAnalyzer extends AbstractAnalyzer<Command> implements CommandAnalyzer
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCommandAnalyzer(Context ctx)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ExpressionanalyzeExpression()protected ExpressionListanalyzeExpressionList()protected LeftValueanalyzeSimpleLeftValue()protected LeftValueListanalyzeSimpleLeftValueList()protected voidassertKeyWord(java.lang.String keyword)Ensures that the appropriate keyword is on the line.protected voidconsumeEndOfLine()Checks that there are no extra characters on a program line when the line analyzer thinks that it has finished analyzing the line.protected static booleanequal(LeftValue a, LeftValue b)Check that the left values are simple (no modifiers, a.k.a.protected java.lang.StringgetName()protected booleanisKeyWord(java.lang.String keyword)protected voidpushNode(NestedStructure node)
-
-
-
Field Detail
-
ctx
protected final Context ctx
-
-
Constructor Detail
-
AbstractCommandAnalyzer
protected AbstractCommandAnalyzer(Context ctx)
-
-
Method Detail
-
equal
protected static boolean equal(LeftValue a, LeftValue b)
Check that the left values are simple (no modifiers, a.k.a. simply variables) and are the same variables (have the same name).- Parameters:
a- variable oneb- variable two- Returns:
trueif the variables have the same name and none of them has modifiers (array access or field access)
-
getName
protected java.lang.String getName()
-
analyzeSimpleLeftValueList
protected LeftValueList analyzeSimpleLeftValueList() throws AnalysisException
- Throws:
AnalysisException
-
analyzeSimpleLeftValue
protected LeftValue analyzeSimpleLeftValue() throws AnalysisException
- Throws:
AnalysisException
-
analyzeExpression
protected Expression analyzeExpression() throws AnalysisException
- Throws:
AnalysisException
-
analyzeExpressionList
protected ExpressionList analyzeExpressionList() throws AnalysisException
- Throws:
AnalysisException
-
pushNode
protected void pushNode(NestedStructure node)
-
assertKeyWord
protected void assertKeyWord(java.lang.String keyword) throws AnalysisExceptionEnsures that the appropriate keyword is on the line. Also it eats up that keyword.- Parameters:
keyword- the keyword that has to be present on the line- Throws:
AnalysisException- when the next lexeme is NOT the expected keyword.
-
isKeyWord
protected boolean isKeyWord(java.lang.String keyword) throws AnalysisException- Throws:
AnalysisException
-
consumeEndOfLine
protected void consumeEndOfLine() throws AnalysisExceptionChecks that there are no extra characters on a program line when the line analyzer thinks that it has finished analyzing the line. If there are some extra characters on the line then throws syntax error exception. Otherwise it simply steps the lexical analyzer iterator over the EOL symbol.- Throws:
AnalysisException- when there are extra character on the actual line
-
-