Package jflex.core
Class LexScan
java.lang.Object
jflex.core.AbstractLexScan
jflex.core.LexScan
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
This character denotes the end of filestatic final int
lexical statesFields inherited from class jflex.core.AbstractLexScan
scanErrorException
Fields inherited from interface jflex.core.sym
ACTION, BANG, BAR, CCLASS, CCLASSNOT, CCLASSOP, CHAR, CHAR_I, CLOSEBRACKET, CLOSECLASS, COMMA, CONCAT, DASH, DELIMITER, DIFFERENCE, DIGITCLASS, DIGITCLASSNOT, DOLLAR, EOF, EOFRULE, EQUALS, error, HAT, IDENT, INTERSECTION, JLETTERCLASS, JLETTERDIGITCLASS, LBRACE, LESSTHAN, LETTERCLASS, LOOKAHEAD, LOWERCLASS, MACROUSE, MORETHAN, NEWLINE, NOACTION, OPENBRACKET, OPENCLASS, PLUS, POINT, PRIMCLASS, QUESTION, RBRACE, REGEXPEND, REPEAT, STAR, STRING, STRING_I, SYMMETRICDIFFERENCE, terminalNames, TILDE, UNION, UNIPROPCCLASS, UNIPROPCCLASSNOT, UPPERCLASS, USERCODE, WHITESPACECLASS, WHITESPACECLASSNOT, WORDCLASS, WORDCLASSNOT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjava_cup.runtime.Symbol
Same as next_token but also prints the token to standard out for debugging.protected int
protected int
lexLine()
protected void
protected String
lexText()
static void
Runs the scanner on input files.java_cup.runtime.Symbol
Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.final boolean
yyatEOF()
Returns whether the scanner has reached the end of the reader it reads from.final void
yybegin
(int newState) Enters a new lexical statefinal char
yycharat
(int pos) Returns the character at positionpos
from the matched text.final void
yyclose()
Closes the input reader.final int
yylength()
How many characters were matched.final boolean
Returns true iff there are still streams left to read from on the stream stack.final void
Closes the current input stream and continues to read from the one on top of the stream stack.void
yypushback
(int number) Pushes the specified amount of characters back into the input stream.final void
yypushStream
(Reader reader) Stores the current input stream on a stack, and reads from a new stream.final void
Resets the scanner to read from a new input stream.final int
yystate()
Returns the current lexical state.final String
yytext()
Returns the text matched by the current regular expression.Methods inherited from class jflex.core.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, getStateNumber, getUnicodeProperties, initCode, initThrow, isAbstract, isColumnCount, isExtending, isFinal, isImplementing, isInteger, isIntWrap, isPublic, lexThrow, lineCount, 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:
lexLine
in classAbstractLexScan
-
lexColumn
protected int lexColumn()- Specified by:
lexColumn
in classAbstractLexScan
-
lexText
- Specified by:
lexText
in classAbstractLexScan
-
lexPushStream
- Specified by:
lexPushStream
in 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 positionpos
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
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 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.
-