Class LexScan
java.lang.Object
jflex.core.AbstractLexScan
jflex.core.LexScan
- All Implemented Interfaces:
java_cup.runtime.Scanner, ILexScan
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractLexScan
AbstractLexScan.CharSetSize -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intThis character denotes the end of filestatic final intlexical statesFields inherited from class AbstractLexScan
scanErrorException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjava_cup.runtime.SymbolSame as next_token but also prints the token to standard out for debugging.protected intprotected intprotected intlexLine()protected voidlexPushback(int n) protected voidprotected StringlexText()static voidRuns the scanner on input files.java_cup.runtime.SymbolResumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.final booleanyyatEOF()Returns whether the scanner has reached the end of the reader it reads from.final voidyybegin(int newState) Enters a new lexical statefinal charyycharat(int pos) Returns the character at positionposfrom the matched text.final voidyyclose()Closes the input reader.final intyylength()How many characters were matched.final booleanReturns true iff there are still streams left to read from on the stream stack.final voidCloses the current input stream and continues to read from the one on top of the stream stack.voidyypushback(int number) Pushes the specified amount of characters back into the input stream.final voidyypushStream(Reader reader) Stores the current input stream on a stack, and reads from a new stream.final voidResets the scanner to read from a new input stream.final intyystate()Returns the current lexical state.final Stringyytext()Returns the text matched by the current regular expression.Methods inherited from class AbstractLexScan
actions, bolUsed, bufferSize, charCount, classCode, className, columnCount, conc, concExc, ctorArg, ctorArgsCount, ctorType, cup2Compatible, cupCompatible, cupDebug, cupSymbol, currentLine, debugOption, eofclose, eofCode, eofThrow, eofVal, file, functionName, getCharClasses, getIntCharSet, getMaximumCodePoint, getStateNumber, getTokenSizeLimit, getUnicodeProperties, initCharClasses, initCharClasses, initCode, initThrow, isAbstract, isColumnCount, isExtending, isFinal, isImplementing, isInteger, isIntWrap, isPublic, lexThrow, lineCount, maybeWarnUnicodeMatch, noSuppressWarnings, scanErrorException, setFile, standalone, stateNames, tokenType, userCode, visibility
-
Field Details
-
YYEOF
public static final int YYEOFThis character denotes the end of file- See Also:
-
YYINITIAL
public static final int YYINITIALlexical states- See Also:
-
COMMENT
public static final int COMMENT- See Also:
-
STATELIST
public static final int STATELIST- See Also:
-
MACROS
public static final int MACROS- See Also:
-
REGEXPSTART
public static final int REGEXPSTART- See Also:
-
REGEXP
public static final int REGEXP- See Also:
-
JAVA_CODE
public static final int JAVA_CODE- See Also:
-
STATES
public static final int STATES- See Also:
-
STRING_CONTENT
public static final int STRING_CONTENT- See Also:
-
CHARCLASS
public static final int CHARCLASS- See Also:
-
COPY
public static final int COPY- See Also:
-
REPEATEXP
public static final int REPEATEXP- See Also:
-
EATWSPNL
public static final int EATWSPNL- See Also:
-
CTOR_ARG
public static final int CTOR_ARG- See Also:
-
REGEXP_CODEPOINT_SEQUENCE
public static final int REGEXP_CODEPOINT_SEQUENCE- See Also:
-
STRING_CODEPOINT_SEQUENCE
public static final int STRING_CODEPOINT_SEQUENCE- See Also:
-
CHARCLASS_CODEPOINT
public static final int CHARCLASS_CODEPOINT- See Also:
-
-
Constructor Details
-
LexScan
Creates a new scanner- Parameters:
in- the java.io.Reader to read input from.
-
-
Method Details
-
lexLine
protected int lexLine()- Specified by:
lexLinein classAbstractLexScan
-
lexColumn
protected int lexColumn()- Specified by:
lexColumnin classAbstractLexScan
-
lexText
- Specified by:
lexTextin classAbstractLexScan
-
lexLength
protected int lexLength()- Specified by:
lexLengthin classAbstractLexScan
-
lexPushback
protected void lexPushback(int n) - Specified by:
lexPushbackin classAbstractLexScan
-
lexPushStream
- Specified by:
lexPushStreamin classAbstractLexScan- Throws:
IOException
-
yyclose
Closes the input reader.- Throws:
IOException- if the reader could not be closed.
-
yypushStream
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
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
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 toZZ_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
Returns the text matched by the current regular expression.- Returns:
- the matched text.
-
yycharat
public final char yycharat(int pos) Returns the character at positionposfrom 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
Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.- Specified by:
next_tokenin interfacejava_cup.runtime.Scanner- Returns:
- the next token
- Throws:
IOException- if any I/O-Error occurs
-
debug_next_token
Same as next_token but also prints the token to standard out for debugging.- Throws:
IOException
-
main
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.
-