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, CommandAnalyzerCase, CommandAnalyzerDSL, CommandAnalyzerEnd, CommandAnalyzerEndSub, CommandAnalyzerFor, CommandAnalyzerLet, CommandAnalyzerMethod, CommandAnalyzerNext, CommandAnalyzerPrint, CommandAnalyzerReturn, CommandAnalyzerSelect, CommandAnalyzerSub, CommandAnalyzerUse, CommandAnalyzerWend, CommandAnalyzerWhile

public abstract class AbstractCommandAnalyzer extends AbstractAnalyzer<Command> implements CommandAnalyzer
  • Field Details

    • ctx

      protected final Context ctx
  • Constructor Details

    • AbstractCommandAnalyzer

      protected AbstractCommandAnalyzer(Context ctx)
  • Method Details

    • 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 one
      b - variable two
      Returns:
      true if the variables have the same name and none of them has modifiers (array access or field access)
    • getName

      protected 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(String keyword) throws AnalysisException
      Ensures 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(String keyword) throws AnalysisException
      Throws:
      AnalysisException
    • consumeEndOfStatement

      protected void consumeEndOfStatement() throws AnalysisException
      Checks that there are no extra characters when the line analyzer expects it has finished analyzing the statement. If there are some extra characters on the line then throws syntax error exception. Otherwise it simply steps the lexical analyzer iterator over the symbol.
      Throws:
      AnalysisException - when there are extra character on the actual line