Class Parser
java.lang.Object
com.opensymphony.module.sitemesh.html.tokenizer.Parser
Looks for patterns of tokens in the Lexer and translates these to calls to pass to the TokenHandler.
- Author:
- Joe Walnes
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final shortThe Constant EQUALS.static final shortThe Constant GT.static final shortThe Constant LT.static final shortThe Constant LT_CLOSE_MAGIC_COMMENT.static final shortThe Constant LT_OPEN_MAGIC_COMMENT.static final shortThe Constant QUOTE.static final shortThe Constant QUOTED.static final shortThe Constant SLASH.static final shortThe Constant TEXT.static final shortThe Constant WHITESPACE.static final shortThe Constant WORD.static final intThis character denotes the end of file.static final int -
Constructor Summary
ConstructorsConstructorDescriptionParser(char[] input, int length, TokenHandler handler) Instantiates a new parser. -
Method Summary
Modifier and TypeMethodDescriptionprotected intcolumn()protected intlength()protected intline()protected voidparsedAttribute(String name, String value, boolean quoted) Parsed attribute.protected voidParsed tag.protected voidparsedText(int position, int length) Parsed text.protected intposition()protected voidreportError(String message, int line, int column) protected voidvoidstart()Start.final booleanyyatEOF()Returns whether the scanner has reached the end of the reader it reads from.final voidyybegin(int newState) Enters a new lexical state.final charyycharat(int position) Returns the character at the given position from the matched text.final voidyyclose()Closes the input reader.final intyylength()How many characters were matched.intyylex()Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.voidyypushback(int number) Pushes the specified amount of characters back into the input 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.
-
Field Details
-
SLASH
public static final short SLASHThe Constant SLASH.- See Also:
-
WHITESPACE
public static final short WHITESPACEThe Constant WHITESPACE.- See Also:
-
EQUALS
public static final short EQUALSThe Constant EQUALS.- See Also:
-
QUOTE
public static final short QUOTEThe Constant QUOTE.- See Also:
-
WORD
public static final short WORDThe Constant WORD.- See Also:
-
TEXT
public static final short TEXTThe Constant TEXT.- See Also:
-
QUOTED
public static final short QUOTEDThe Constant QUOTED.- See Also:
-
LT
public static final short LTThe Constant LT.- See Also:
-
GT
public static final short GTThe Constant GT.- See Also:
-
LT_OPEN_MAGIC_COMMENT
public static final short LT_OPEN_MAGIC_COMMENTThe Constant LT_OPEN_MAGIC_COMMENT.- See Also:
-
LT_CLOSE_MAGIC_COMMENT
public static final short LT_CLOSE_MAGIC_COMMENTThe Constant LT_CLOSE_MAGIC_COMMENT.- See Also:
-
YYEOF
public static final int YYEOFThis character denotes the end of file.- See Also:
-
YYINITIAL
public static final int YYINITIAL- See Also:
-
ELEMENT
public static final int ELEMENT- See Also:
-
-
Constructor Details
-
Parser
Instantiates a new parser.- Parameters:
input- the inputlength- the lengthhandler- the handler
-
-
Method Details
-
start
public void start()Start. -
parsedText
protected void parsedText(int position, int length) Parsed text.- Parameters:
position- the positionlength- the length
-
parsedTag
Parsed tag.- Parameters:
type- the typename- the namestart- the startlength- the length
-
parsedAttribute
Parsed attribute.- Parameters:
name- the namevalue- the valuequoted- the quoted
-
reportError
-
position
protected int position() -
length
protected int length() -
line
protected int line() -
column
protected int column() -
resetLexerState
protected void resetLexerState() -
yyclose
Closes the input reader.- Throws:
IOException- if the reader could not be closed.
-
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 to
ZZ_INITIAL.Internal scan buffer is resized down to its initial length, if it has grown.
- Parameters:
reader- The new input stream.
-
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 position) Returns the character at the given position from the matched text.It is equivalent to
yytext().charAt(pos), but faster.- Parameters:
position- the position of the character to fetch. A value from 0 toyylength()-1.- Returns:
- the character at
position.
-
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 thanyylength().
-
yylex
Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.- Returns:
- the next token.
- Throws:
IOException- if any I/O-Error occurs.
-