Package jflex.core

Class LexScan

All Implemented Interfaces:
java_cup.runtime.Scanner, sym, ILexScan

public final class LexScan extends AbstractLexScan implements sym, java_cup.runtime.Scanner
  • Field Details

  • Constructor Details

    • LexScan

      public LexScan(Reader in)
      Creates a new scanner
      Parameters:
      in - the java.io.Reader to read input from.
  • Method Details

    • lexLine

      protected int lexLine()
      Specified by:
      lexLine in class AbstractLexScan
    • lexColumn

      protected int lexColumn()
      Specified by:
      lexColumn in class AbstractLexScan
    • lexText

      protected String lexText()
      Specified by:
      lexText in class AbstractLexScan
    • lexPushStream

      protected void lexPushStream(File f) throws IOException
      Specified by:
      lexPushStream in class AbstractLexScan
      Throws:
      IOException
    • yyclose

      public final void yyclose() throws IOException
      Closes the input reader.
      Throws:
      IOException - if the reader could not be closed.
    • yypushStream

      public final void yypushStream(Reader reader)
      Stores the current input stream on a stack, and reads from a new stream. Lexical state, line, char, and column counting remain untouched. The current input stream can be restored with yypopStream (usually in an <<EOF>> action).
      Parameters:
      reader - the new input stream to read from
      See Also:
    • yypopStream

      public final void yypopStream() throws IOException
      Closes the current input stream and continues to read from the one on top of the stream stack.
      Throws:
      NoSuchElementException - if there is no further stream to read from.
      IOException - if there was an error in closing the stream.
      See Also:
    • yymoreStreams

      public final boolean yymoreStreams()
      Returns true iff there are still streams left to read from on the stream stack.
    • yyreset

      public final void yyreset(Reader reader)
      Resets the scanner to read from a new input stream. Does not close the old reader. All internal variables are reset, the old input stream cannot be reused (internal buffer is discarded and lost). Lexical state is set to ZZ_INITIAL. Internal scan buffer is resized down to its initial length, if it has grown.
      Parameters:
      reader - the new input stream
      See Also:
    • yyatEOF

      public final boolean yyatEOF()
      Returns whether the scanner has reached the end of the reader it reads from.
      Returns:
      whether the scanner has reached EOF.
    • yystate

      public final int yystate()
      Returns the current lexical state.
      Returns:
      the current lexical state.
    • yybegin

      public final void yybegin(int newState)
      Enters a new lexical state
      Parameters:
      newState - the new lexical state
    • yytext

      public final String yytext()
      Returns the text matched by the current regular expression.
      Returns:
      the matched text.
    • yycharat

      public final char yycharat(int pos)
      Returns the character at position pos from the matched text. It is equivalent to yytext().charAt(pos), but faster
      Parameters:
      pos - the position of the character to fetch. A value from 0 to yylength()-1.
      Returns:
      the character at position pos
    • yylength

      public final int yylength()
      How many characters were matched.
      Returns:
      the length of the matched text region.
    • yypushback

      public void yypushback(int number)
      Pushes the specified amount of characters back into the input stream. They will be read again by then next call of the scanning method
      Parameters:
      number - the number of characters to be read again. This number must not be greater than yylength()!
    • next_token

      public java_cup.runtime.Symbol next_token() throws IOException
      Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.
      Specified by:
      next_token in interface java_cup.runtime.Scanner
      Returns:
      the next token
      Throws:
      IOException - if any I/O-Error occurs
    • debug_next_token

      public java_cup.runtime.Symbol debug_next_token() throws IOException
      Same as next_token but also prints the token to standard out for debugging.
      Throws:
      IOException
    • main

      public static void main(String[] argv)
      Runs the scanner on input files. This main method is the debugging routine for the scanner. It prints debugging information about each returned token to System.out until the end of file is reached, or an error occured.
      Parameters:
      argv - the command line, contains the filenames to run the scanner on.