Package jflex.core
Class LexScan
- java.lang.Object
-
- jflex.core.AbstractLexScan
-
- jflex.core.LexScan
-
public final class LexScan extends AbstractLexScan implements sym, java_cup.runtime.Scanner
-
-
Field Summary
Fields Modifier and Type Field Description static int
CHARCLASS
static int
CHARCLASS_CODEPOINT
static int
COMMENT
static int
COPY
static int
CTOR_ARG
static int
EATWSPNL
static int
JAVA_CODE
static int
MACROS
static int
REGEXP
static int
REGEXP_CODEPOINT_SEQUENCE
static int
REGEXPSTART
static int
REPEATEXP
static int
STATELIST
static int
STATES
static int
STRING_CODEPOINT_SEQUENCE
static int
STRING_CONTENT
static int
YYEOF
This character denotes the end of filestatic int
YYINITIAL
lexical states-
Fields inherited from class jflex.core.AbstractLexScan
scanErrorException
-
Fields inherited from interface jflex.core.sym
ACTION, ASCII, BANG, BAR, CCLASS, CCLASSNOT, CCLASSOP, CHAR, CHAR_I, CLOSEBRACKET, CLOSECLASS, COMMA, CONCAT, DASH, DELIMITER, DIFFERENCE, DIGITCLASS, DIGITCLASSNOT, DOLLAR, EOF, EOFRULE, EQUALS, error, FULL, 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, UNICODE, UNION, UNIPROPCCLASS, UNIPROPCCLASSNOT, UPPERCLASS, USERCODE, WHITESPACECLASS, WHITESPACECLASSNOT, WORDCLASS, WORDCLASSNOT
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java_cup.runtime.Symbol
debug_next_token()
Same as next_token but also prints the token to standard out for debugging.protected int
lexColumn()
protected int
lexLine()
protected void
lexPushStream(File f)
protected String
lexText()
static void
main(String[] argv)
Runs the scanner on input files.java_cup.runtime.Symbol
next_token()
Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.boolean
yyatEOF()
Returns whether the scanner has reached the end of the reader it reads from.void
yybegin(int newState)
Enters a new lexical statechar
yycharat(int pos)
Returns the character at positionpos
from the matched text.void
yyclose()
Closes the input reader.int
yylength()
How many characters were matched.boolean
yymoreStreams()
Returns true iff there are still streams left to read from on the stream stack.void
yypopStream()
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.void
yypushStream(Reader reader)
Stores the current input stream on a stack, and reads from a new stream.void
yyreset(Reader reader)
Resets the scanner to read from a new input stream.int
yystate()
Returns the current lexical state.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 Detail
-
YYEOF
public static final int YYEOF
This character denotes the end of file- See Also:
- Constant Field Values
-
YYINITIAL
public static final int YYINITIAL
lexical states- See Also:
- Constant Field Values
-
COMMENT
public static final int COMMENT
- See Also:
- Constant Field Values
-
STATELIST
public static final int STATELIST
- See Also:
- Constant Field Values
-
MACROS
public static final int MACROS
- See Also:
- Constant Field Values
-
REGEXPSTART
public static final int REGEXPSTART
- See Also:
- Constant Field Values
-
REGEXP
public static final int REGEXP
- See Also:
- Constant Field Values
-
JAVA_CODE
public static final int JAVA_CODE
- See Also:
- Constant Field Values
-
STATES
public static final int STATES
- See Also:
- Constant Field Values
-
STRING_CONTENT
public static final int STRING_CONTENT
- See Also:
- Constant Field Values
-
CHARCLASS
public static final int CHARCLASS
- See Also:
- Constant Field Values
-
COPY
public static final int COPY
- See Also:
- Constant Field Values
-
REPEATEXP
public static final int REPEATEXP
- See Also:
- Constant Field Values
-
EATWSPNL
public static final int EATWSPNL
- See Also:
- Constant Field Values
-
CTOR_ARG
public static final int CTOR_ARG
- See Also:
- Constant Field Values
-
REGEXP_CODEPOINT_SEQUENCE
public static final int REGEXP_CODEPOINT_SEQUENCE
- See Also:
- Constant Field Values
-
STRING_CODEPOINT_SEQUENCE
public static final int STRING_CODEPOINT_SEQUENCE
- See Also:
- Constant Field Values
-
CHARCLASS_CODEPOINT
public static final int CHARCLASS_CODEPOINT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LexScan
public LexScan(Reader in)
Creates a new scanner- Parameters:
in
- the java.io.Reader to read input from.
-
-
Method Detail
-
lexLine
protected int lexLine()
- Specified by:
lexLine
in classAbstractLexScan
-
lexColumn
protected int lexColumn()
- Specified by:
lexColumn
in classAbstractLexScan
-
lexText
protected String lexText()
- Specified by:
lexText
in classAbstractLexScan
-
lexPushStream
protected void lexPushStream(File f) throws IOException
- Specified by:
lexPushStream
in classAbstractLexScan
- 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()
-
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:
yypushStream(java.io.Reader)
-
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 toZZ_INITIAL
. Internal scan buffer is resized down to its initial length, if it has grown.- Parameters:
reader
- the new input stream- See Also:
yypushStream(java.io.Reader)
,yypopStream()
-
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 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
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 interfacejava_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.
-
-