Class PerlSymbolTokenizer
java.lang.Object
org.opengrok.indexer.analysis.JFlexStateStacker
org.opengrok.indexer.analysis.JFlexSymbolMatcher
org.opengrok.indexer.analysis.perl.PerlSymbolTokenizer
- All Implemented Interfaces:
JFlexJointLexer,JFlexLexer,JFlexStackingLexer,Resettable,ScanningSymbolMatcher,SymbolMatchedPublisher
-
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 intThis character denotes the end of file.static final intFields inherited from class org.opengrok.indexer.analysis.JFlexStateStacker
lineNumber, stack -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanGets a value indicating if modifiers are OK at the end of the last quote-like operator.voidbracedSigilID(String capture) Splits a braced sigil identifier -- where thecapturestarts with a sigil and ends with a '}' and where Perl allows whitespace after the sigil and around the identifier -- and write the parts to output.voidchkLOC()CallsJFlexJointLexer.phLOC()if the yystate is not SCOMMENT or POD.voiddisjointSpan(String className) Indicates the closing of an open tag and the opening -- ifclassNameis non-null -- of a new one.Gets a pattern to match the collateral capture for the current quoting state or null if there is no active quoting state.longGets the yychar value.intgetYYEOF()Gets the YYEOF value.voidParses a Here-document declaration, and takes thecaptureusingJFlexJointLexer.offer(java.lang.String).voidBegins a quote-like state for a heuristic match of the shorthand // of m// where thecaptureends with "/", begins with punctuation, and the intervening whitespace may contain LFs -- and writes the parts to output.voidhqopSymbol(String capture) Begins a quote-like state for a heuristic match of the shorthand // of m// where thecaptureends with "/", begins with an initial symbol, and the intervening whitespace may contain LFs -- and writes the parts to output.booleanmaybeEndHere(String capture) Process thecapture, possibly ending the Here-document state just beforehand.booleanmaybeEndQuote(String capture) Determine if the quote should end based on the first character ofcapture, recognizing quote-like operators that allow nesting to increase the nesting level if appropriate.voidbooleanPushes the first Here-document state if any declarations were parsed, or else does nothing.voidPasses non-symbolic fragment for processing.voidofferKeyword(String value) Passes a text fragment that is syntactically a keyword symbol for processing.booleanofferSymbol(String value, int captureOffset, boolean ignoreKwd) Passes a text fragment that is syntactically a symbol for processing.voidphLOC()Indicates that eligible source code was encountered for physical lines-of-code count (physical LOC).voidStarts a quote-like operator as specified in a syntax fragment,op, and gives thecapturefor thelexerto take ifdoWriteis true.voidStarts a quote-like operator as specified in a syntax fragment,op, and gives theopfor thelexerto take.voidreset()Resets the Perl tracked state; Resets the instance to an initial state.protected booleanvoidSets the jflex state reflectingltpostopandnointerp.voidSplits a sigil identifier -- where thecapturestarts with a sigil and ends in an identifier and where Perl allows whitespace after the sigil -- and write the parts to output.protected voidvoidIndicates that something unusual happened where normally a symbol would have been offered.voidWrite a special identifier as a keyword -- unlessendqcharis in thecapture, which will affect an active quote-like operator instead.voidIndicates that the current line is ended.protected booleanfinal 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.Methods inherited from class org.opengrok.indexer.analysis.JFlexSymbolMatcher
clearNonSymbolMatchedListener, clearSymbolMatchedListener, getDisjointSpanClassName, onDisjointSpanChanged, onEmailAddressMatched, onEndOfLineMatched, onFilelikeMatched, onFilteredSymbolMatched, onFilteredSymbolMatched, onKeywordMatched, onLabelDefMatched, onLabelMatched, onNonSymbolMatched, onNonSymbolMatched, onNonSymbolMatched, onPathlikeMatched, onQueryTermMatched, onRefsTermMatched, onScopeChanged, onSourceCodeSeen, onSymbolMatched, onUriMatched, onUriMatched, setNonSymbolMatchedListener, setSymbolMatchedListenerMethods inherited from class org.opengrok.indexer.analysis.JFlexStateStacker
clearStack, emptyStack, getLineNumber, setLineNumber, yyjump, yypop, yypushMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opengrok.indexer.analysis.JFlexStackingLexer
emptyStack, getLineNumber, yypop, yypush
-
Field Details
-
YYEOF
public static final int YYEOFThis character denotes the end of file.- See Also:
-
YYINITIAL
public static final int YYINITIAL- See Also:
-
INTRA
public static final int INTRA- See Also:
-
SCOMMENT
public static final int SCOMMENT- See Also:
-
POD
public static final int POD- See Also:
-
FMT
public static final int FMT- See Also:
-
QUO
public static final int QUO- See Also:
-
QUOxN
public static final int QUOxN- See Also:
-
QUOxL
public static final int QUOxL- See Also:
-
QUOxLxN
public static final int QUOxLxN- See Also:
-
QM
public static final int QM- See Also:
-
HERE
public static final int HERE- See Also:
-
HERExN
public static final int HERExN- See Also:
-
HEREin
public static final int HEREin- See Also:
-
HEREinxN
public static final int HEREinxN- See Also:
-
-
Constructor Details
-
PerlSymbolTokenizer
Creates a new scanner- Parameters:
in- the java.io.Reader to read input from.
-
-
Method Details
-
getYYCHAR
public long getYYCHAR()Gets the yychar value.- Returns:
- yychar
-
getYYEOF
public int getYYEOF()Gets the YYEOF value.- Specified by:
getYYEOFin interfaceJFlexStackingLexer- Specified by:
getYYEOFin classJFlexStateStacker- Returns:
- YYEOF
-
reset
public void reset()Resets the Perl tracked state; Resets the instance to an initial state.- Specified by:
resetin interfaceResettable
-
offer
Description copied from interface:JFlexJointLexerPasses non-symbolic fragment for processing.- Parameters:
value- the excised fragment- Throws:
IOException- if an error occurs while accepting
-
offerSymbol
Description copied from interface:JFlexJointLexerPasses a text fragment that is syntactically a symbol for processing.- Parameters:
value- the excised symbolcaptureOffset- the offset from yychar wherevaluebeganignoreKwd- a value indicating whether keywords should be ignored- Returns:
- true if the
valuewas not in keywords or if theignoreKwdwas true - Throws:
IOException- if an error occurs while accepting
-
skipSymbol
public void skipSymbol()Description copied from interface:JFlexJointLexerIndicates that something unusual happened where normally a symbol would have been offered. -
offerKeyword
Description copied from interface:JFlexJointLexerPasses a text fragment that is syntactically a keyword symbol for processing.- Parameters:
value- the excised symbol- Throws:
IOException- if an error occurs while accepting
-
startNewLine
Description copied from interface:JFlexJointLexerIndicates that the current line is ended.- Throws:
IOException- if an error occurs when handling the EOL
-
disjointSpan
Description copied from interface:JFlexJointLexerIndicates the closing of an open tag and the opening -- ifclassNameis non-null -- of a new one.- Parameters:
className- the class name for the new tag ornulljust to close an open tag.- Throws:
IOException- if an output error occurs
-
phLOC
public void phLOC()Description copied from interface:JFlexJointLexerIndicates that eligible source code was encountered for physical lines-of-code count (physical LOC). -
abortQuote
- Throws:
IOException
-
maybeIntraState
public void maybeIntraState() -
takeAllContent
protected boolean takeAllContent() -
returnOnSymbol
protected boolean returnOnSymbol() -
skipLink
-
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.
-
maybeEndQuote
Determine if the quote should end based on the first character ofcapture, recognizing quote-like operators that allow nesting to increase the nesting level if appropriate.Calling this method has side effects to possibly modify
nqchar,waitq, orendqchar.- Returns:
- true if the quote state should end
-
areModifiersOK
public boolean areModifiersOK()Gets a value indicating if modifiers are OK at the end of the last quote-like operator.- Returns:
- true if modifiers are OK
-
qop
Starts a quote-like operator as specified in a syntax fragment,op, and gives theopfor thelexerto take.- Throws:
IOException
-
qop
public void qop(boolean doWrite, String capture, int namelength, boolean nointerp) throws IOException Starts a quote-like operator as specified in a syntax fragment,op, and gives thecapturefor thelexerto take ifdoWriteis true.- Throws:
IOException
-
setState
Sets the jflex state reflectingltpostopandnointerp. -
hqopPunc
Begins a quote-like state for a heuristic match of the shorthand // of m// where thecaptureends with "/", begins with punctuation, and the intervening whitespace may contain LFs -- and writes the parts to output.- Throws:
IOException
-
hqopSymbol
Begins a quote-like state for a heuristic match of the shorthand // of m// where thecaptureends with "/", begins with an initial symbol, and the intervening whitespace may contain LFs -- and writes the parts to output.- Throws:
IOException
-
hop
Parses a Here-document declaration, and takes thecaptureusingJFlexJointLexer.offer(java.lang.String). If the declaration is valid,hereSettingswill have been appended.- Throws:
IOException
-
maybeStartHere
Pushes the first Here-document state if any declarations were parsed, or else does nothing.- Returns:
- true if a Here state was pushed
- Throws:
IOException
-
maybeEndHere
Process thecapture, possibly ending the Here-document state just beforehand.- Returns:
- true if the quote state ended
- Throws:
IOException
-
sigilID
Splits a sigil identifier -- where thecapturestarts with a sigil and ends in an identifier and where Perl allows whitespace after the sigil -- and write the parts to output.Seeing the
endqcharin the capture will affect an active quote-like operator.- Throws:
IOException
-
bracedSigilID
Splits a braced sigil identifier -- where thecapturestarts with a sigil and ends with a '}' and where Perl allows whitespace after the sigil and around the identifier -- and write the parts to output.- Throws:
IOException
-
specialID
Write a special identifier as a keyword -- unlessendqcharis in thecapture, which will affect an active quote-like operator instead.- Throws:
IOException
-
getCollateralCapturePattern
Gets a pattern to match the collateral capture for the current quoting state or null if there is no active quoting state.- Returns:
- a defined pattern or null
-
chkLOC
public void chkLOC()CallsJFlexJointLexer.phLOC()if the yystate is not SCOMMENT or POD.
-