PlainLineTokenizer.java revision c23e82b612acd5e947c164114377578116f6d298
/* The following code was generated by JFlex 1.4.1 on 2/22/06 1:19 AM */
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* ident "@(#)PlainLineTokenizer.lex 1.2 06/02/22 SMI"
*/
/**
* for plain text tokenizers
*/
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.1
* on 2/22/06 1:19 AM from the specification file
* <tt>/home/cb117521/prj/opengrok-0.3/src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex</tt>
*/
public class PlainLineTokenizer {
/** This character denotes the end of file */
public static final int YYEOF = -1;
/** initial size of the lookahead buffer */
private static final int ZZ_BUFFERSIZE = 16384;
/** lexical states */
public static final int YYINITIAL = 0;
/**
* Translates characters to character classes
*/
private static final String ZZ_CMAP_PACKED =
"\12\0\1\12\31\0\3\11\4\0\1\11\1\0\1\11\1\3\1\0"+
"\1\4\11\2\1\11\2\0\1\11\1\0\2\11\6\10\21\1\1\6"+
"\2\1\1\5\1\0\1\7\1\11\1\1\1\0\6\10\21\1\1\6"+
"\2\1\uff85\0";
/**
* Translates characters to character classes
*/
/**
* Translates DFA states to action switch labels.
*/
private static final int [] ZZ_ACTION = zzUnpackAction();
private static final String ZZ_ACTION_PACKED_0 =
"\1\0\1\1\4\2\1\3\2\0\1\2\3\0\1\2";
private static int [] zzUnpackAction() {
int [] result = new int[14];
int offset = 0;
return result;
}
int i = 0; /* index in packed string */
int j = offset; /* index in unpacked array */
while (i < l) {
}
return j;
}
/* error codes */
private static final int ZZ_UNKNOWN_ERROR = 0;
private static final int ZZ_NO_MATCH = 1;
private static final int ZZ_PUSHBACK_2BIG = 2;
/* error messages for the codes above */
private static final String ZZ_ERROR_MSG[] = {
"Unkown internal scanner error",
"Error: could not match input",
"Error: pushback value was too large"
};
/** the input device */
/** the current state of the DFA */
private int zzState;
/** the current lexical state */
private int zzLexicalState = YYINITIAL;
/** this buffer contains the current text to be matched and is
the source of the yytext() string */
private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
/** the textposition at the last accepting state */
private int zzMarkedPos;
/** the textposition at the last state to be included in yytext */
private int zzPushbackPos;
/** the current text position in the buffer */
private int zzCurrentPos;
/** startRead marks the beginning of the yytext() string in the buffer */
private int zzStartRead;
/** endRead marks the last character in the buffer, that has been read
from input */
private int zzEndRead;
/** number of newlines encountered up to the start of the matched text */
private int yyline;
/** the number of characters up to the start of the matched text */
private int yychar;
/**
* the number of characters from the last newline up to the start of the
* matched text
*/
private int yycolumn;
/**
* zzAtBOL == true <=> the scanner is currently at the beginning of a line
*/
private boolean zzAtBOL = true;
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
/* user code: */
int markedPos=0;
int curLinePos=0;
int matchStart=-1;
int markedLine=0;
int rest=0;
boolean wait = false;
boolean dumpRest = false;
boolean prevHi = false;
boolean alt;
/**
* Set the writer that should receive all output
* @param out The new writer to write to
*/
yyline = 1;
}
/*
* This would be faster than yytext().tolowercase()
*/
public String loweryytext() {
int k = 0;
for(int i = zzStartRead; i < zzMarkedPos; i++) {
char s = zzBuffer[i];
if(s >= 'A' && s <= 'Z') {
lcs[k++] =(char)(s + 32);
} else {
lcs[k++]= s;
}
}
}
/**
* Set the name of the file we are working on (needed if we would like to
* generate a list of hits instead of generating html)
* @param filename the name of the file
*/
}
/**
* Set the list we should create Hit objects for
* @param hits the hits we should add Hit objects
*/
}
/**
* Set the name of the file we are working on (needed if we would like to
* generate a list of hits instead of generating html)
* @param filename the name of the file
*/
}
zzStartRead = 0;
zzAtEOF = true;
wait = false;
dumpRest = false;
rest = 0;
markedPos=0;
curLinePos=0;
matchStart=-1;
markedLine=0;
yyline = 1;
}
prevHi = false;
}
zzStartRead = 0;
wait = false;
dumpRest = false;
rest = 0;
markedPos=0;
curLinePos=0;
matchStart=-1;
markedLine=0;
yyline = 1;
}
prevHi = false;
}
public void holdOn() {
if(!wait) {
wait = true;
}
}
public void neverMind() {
wait = false;
if(!dumpRest) {
markedLine = yyline;
}
matchStart = -1;
}
switch(buf[i]) {
case '\n':
++lineNo;
if(prevHi){
}
break;
case '<':
break;
case '>':
break;
case '&':
break;
default:
}
}
return lineNo;
}
switch(buf[i]) {
case '\n':
++lineNo;
if(prevHi){
}
break;
case '<':
break;
case '>':
break;
case '&':
break;
default:
}
}
return lineNo;
}
public void printContext() throws IOException {
sb = new StringBuilder();
}
}
wait = false;
if (matchStart == -1) {
}
if(curLinePos == markedPos) {
if (prevHi) {
}
}
}
} else {
}
matchStart = -1;
dumpRest = true;
rest = zzMarkedPos;
}
public void dumpRest() throws IOException {
if(dumpRest) {
//out.write(zzBuffer, rest, i);
if (prevHi) {
}
} else {
if (prevHi) {
}
}
break;
}
}
}
}
} else {
}
}
}
}
/**
* Creates a new scanner
* There is also a java.io.InputStream version of this constructor.
*
* @param in the java.io.Reader to read input from.
*/
}
/**
* Creates a new scanner.
* There is also java.io.Reader version of this constructor.
*
* @param in the java.io.Inputstream to read input from.
*/
}
/**
* Unpacks the compressed character translation table.
*
* @param packed the packed character translation table
* @return the unpacked character translation table
*/
char [] map = new char[0x10000];
int i = 0; /* index in packed string */
int j = 0; /* index in unpacked array */
while (i < 64) {
}
return map;
}
/**
* Refills the input buffer.
*
* @return <code>false</code>, iff there was new input.
*
*/
/* first: make room (if you can) */
if (zzStartRead > 0) {
zzBuffer, 0,
/* translate stored positions */
zzStartRead = 0;
}
/* is the buffer big enough? */
/* if not: blow it up */
}
/* finally: fill the buffer with new input */
if (numRead < 0) {
return true;
}
else {
return false;
}
}
/**
* Closes the input stream.
*/
zzAtEOF = true; /* indicate end of file */
}
/**
* 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
* <b>cannot</b> be reused (internal buffer is discarded and lost).
* Lexical state is set to <tt>ZZ_INITIAL</tt>.
*
* @param reader the new input stream
*/
zzAtBOL = true;
zzAtEOF = false;
}
/**
* Returns the current lexical state.
*/
public final int yystate() {
return zzLexicalState;
}
/**
* Enters a new lexical state
*
* @param newState the new lexical state
*/
}
/**
* Returns the text matched by the current regular expression.
*/
}
/**
* Returns the character at position <tt>pos</tt> from the
* matched text.
*
* It is equivalent to yytext().charAt(pos), but faster
*
* @param pos the position of the character to fetch.
* A value from 0 to yylength()-1.
*
* @return the character at position pos
*/
}
/**
* Returns the length of the matched text region.
*/
public final int yylength() {
return zzMarkedPos-zzStartRead;
}
/**
* Reports an error that occured while scanning.
*
* In a wellformed scanner (no or only correct usage of
* yypushback(int) and a match-all fallback rule) this method
* will only be called with things that "Can't Possibly Happen".
* If this method is called, something is seriously wrong
* (e.g. a JFlex bug producing a faulty scanner etc.).
*
* in error fallback rules.
*
* @param errorCode the code of the errormessage to display
*/
private void zzScanError(int errorCode) {
try {
}
catch (ArrayIndexOutOfBoundsException e) {
}
}
/**
* Pushes the specified amount of characters back into the input stream.
*
* They will be read again by then next call of the scanning method
*
* @param number the number of characters to be read again.
* This number must not be greater than yylength()!
*/
public void yypushback(int number) {
zzMarkedPos -= number;
}
/**
* Resumes scanning until the next regular expression is matched,
*
* @return the next token
*/
int zzInput;
int zzAction;
// cached fields:
int zzCurrentPosL;
int zzMarkedPosL;
int zzEndReadL = zzEndRead;
while (true) {
boolean zzR = false;
zzCurrentPosL++) {
switch (zzBufferL[zzCurrentPosL]) {
case '\u000B':
case '\u000C':
case '\u0085':
case '\u2028':
case '\u2029':
yyline++;
zzR = false;
break;
case '\r':
yyline++;
zzR = true;
break;
case '\n':
if (zzR)
zzR = false;
else {
yyline++;
}
break;
default:
zzR = false;
}
}
if (zzR) {
// peek one character ahead if it is \n (if we have counted one line too much)
boolean zzPeek;
if (zzMarkedPosL < zzEndReadL)
else if (zzAtEOF)
zzPeek = false;
else {
if (eof)
zzPeek = false;
else
}
}
zzAction = -1;
zzForAction: {
while (true) {
if (zzCurrentPosL < zzEndReadL)
else if (zzAtEOF) {
break zzForAction;
}
else {
// store back cached positions
// get translated positions and possibly new buffer
if (eof) {
break zzForAction;
}
else {
}
}
boolean zzIsFinal = false;
boolean zzNoLookAhead = false;
case 0:
switch (zzInput) {
case 1:
case 6:
case 3:
}
case 2:
switch (zzInput) {
case 1:
case 2:
case 4:
case 6:
default: break zzForAction;
}
case 3:
switch (zzInput) {
case 2:
default: break zzForAction;
}
case 5:
switch (zzInput) {
case 2:
default: break zzForAction;
}
case 7:
switch (zzInput) {
case 2:
default: break zzForAction;
}
case 8:
switch (zzInput) {
default: break zzForAction;
}
case 9:
switch (zzInput) {
case 2:
default: break zzForAction;
}
case 10:
switch (zzInput) {
default: break zzForAction;
}
case 11:
switch (zzInput) {
default: break zzForAction;
}
case 12:
switch (zzInput) {
case 2:
case 4:
default: break zzForAction;
}
case 13:
switch (zzInput) {
case 2:
case 4:
default: break zzForAction;
}
default:
// if this is ever reached, there is a serious bug in JFlex
break;
} }
if ( zzIsFinal ) {
if ( zzNoLookAhead ) break zzForAction;
}
}
}
// store back cached position
case 2:
{ return loweryytext();
}
case 4: break;
case 3:
{ if(!wait) {
matchStart = -1;
}
if(dumpRest) {
if(prevHi){
}
} else {
if(prevHi){
}
}
dumpRest = false;
}
}
case 5: break;
case 1:
{
}
case 6: break;
default:
zzAtEOF = true;
{
return null;
}
}
else {
}
}
}
}
}