Class AntlrLexicalAnalyzer

java.lang.Object
net.emustudio.emulib.plugin.compiler.antlr.AntlrLexicalAnalyzer
All Implemented Interfaces:
LexicalAnalyzer

public class AntlrLexicalAnalyzer extends Object implements LexicalAnalyzer
Lexical analyzer backed by ANTLR lexer. ANTLR token types are mapped to emuLib Token types.
  • Field Details

    • lexer

      protected final org.antlr.v4.runtime.Lexer lexer
  • Constructor Details

    • AntlrLexicalAnalyzer

      public AntlrLexicalAnalyzer(org.antlr.v4.runtime.Lexer lexer, int[] tokenMap, String lineCommentStart)
      Parameters:
      lexer - ANTLR lexer
      tokenMap - mapping from ANTLR token type (index) to Token type
      lineCommentStart - line comment opening text, or null if unsupported
  • Method Details

    • getLineCommentStartAndEnd

      public String[] getLineCommentStartAndEnd()
      Description copied from interface: LexicalAnalyzer
      Line comment opening and optional closing text, or null if unsupported.
      Specified by:
      getLineCommentStartAndEnd in interface LexicalAnalyzer
    • next

      public Token next()
      Description copied from interface: LexicalAnalyzer
      Parse next token.
      Specified by:
      next in interface LexicalAnalyzer
      Returns:
      next token, or Token.EOF if no token is available on the input
    • hasNext

      public boolean hasNext()
      Description copied from interface: LexicalAnalyzer
      Determines if a next token is available on the input at the current lexer position.
      Specified by:
      hasNext in interface LexicalAnalyzer
      Returns:
      true if the lexer has a next token to be parsed
    • reset

      public void reset(char[] array, int offset, int length)
      Description copied from interface: LexicalAnalyzer
      Reset this lexical analyzer with new input.
      Specified by:
      reset in interface LexicalAnalyzer
      Parameters:
      array - new program source code
      offset - the index of the first character to read
      length - length of how much to read