Class Lexer

java.lang.Object
codeanalysis.syntax.Lexer

public class Lexer extends Object
The Lexer class is responsible for lexical analysis of a given text, producing tokens that represent different elements of the text. It scans the text character by character and generates tokens based on specific rules.
Version:
1.0
Author:
Siyabend Urun
See Also:
  • Constructor Details

    • Lexer

      public Lexer(SourceText text)
      Initializes a new instance of the Lexer class with the specified text to analyze.
      Parameters:
      text - The text to analyze.
  • Method Details

    • getPosition

      public int getPosition()
      Gets the current position of the lexer in the text.
      Returns:
      The current position of the lexer.
    • currentChar

      public char currentChar()
      Gets the current character being analyzed by the lexer.
      Returns:
      The current character being analyzed.
    • diagnostics

      public DiagnosticBox diagnostics()
      Gets an iterator over the diagnostic messages generated during lexical analysis.
      Returns:
      An iterator over the diagnostic messages.
    • getNextToken

      public SyntaxToken getNextToken()
      Retrieves the next token from the text being analyzed. This method scans the text character by character and generates tokens based on specific rules.
      Returns:
      The next token in the text.