tinydoclexer.java
来自「plugin for eclipse」· Java 代码 · 共 332 行
JAVA
332 行
// $ANTLR : "TinyDoc.g" -> "TinyDocLexer.java"$
package isis.anp.nesc;
import java.io.InputStream;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.TokenStreamRecognitionException;
import antlr.CharStreamException;
import antlr.CharStreamIOException;
import antlr.ANTLRException;
import java.io.Reader;
import java.util.Hashtable;
import antlr.CharScanner;
import antlr.InputBuffer;
import antlr.ByteBuffer;
import antlr.CharBuffer;
import antlr.Token;
import antlr.CommonToken;
import antlr.RecognitionException;
import antlr.NoViableAltForCharException;
import antlr.MismatchedCharException;
import antlr.TokenStream;
import antlr.ANTLRHashString;
import antlr.LexerSharedInputState;
import antlr.collections.impl.BitSet;
import antlr.SemanticException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Hashtable;
import antlr.ANTLRHashString;
import antlr.ByteBuffer;
import antlr.CharBuffer;
import antlr.CharStreamException;
import antlr.CharStreamIOException;
import antlr.InputBuffer;
import antlr.LexerSharedInputState;
import antlr.NoViableAltForCharException;
import antlr.RecognitionException;
import antlr.SemanticException;
import antlr.Token;
import antlr.TokenStream;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.TokenStreamRecognitionException;
import antlr.collections.impl.BitSet;
public class TinyDocLexer extends antlr.CharScanner implements TinyDocParserTokenTypes, TokenStream
{
public TinyDocLexer(InputStream in) {
this(new ByteBuffer(in));
}
public TinyDocLexer(Reader in) {
this(new CharBuffer(in));
}
public TinyDocLexer(InputBuffer ib) {
this(new LexerSharedInputState(ib));
}
public TinyDocLexer(LexerSharedInputState state) {
super(state);
caseSensitiveLiterals = true;
setCaseSensitive(true);
literals = new Hashtable();
literals.put(new ANTLRHashString("@see", this), new Integer(11));
literals.put(new ANTLRHashString("@return", this), new Integer(10));
literals.put(new ANTLRHashString("@param", this), new Integer(8));
literals.put(new ANTLRHashString("@author", this), new Integer(12));
}
public Token nextToken() throws TokenStreamException {
Token theRetToken=null;
tryAgain:
for (;;) {
Token _token = null;
int _ttype = Token.INVALID_TYPE;
resetText();
try { // for char stream error handling
try { // for lexical error handling
switch ( LA(1)) {
case '\n': case '\r':
{
mNL(true);
theRetToken=_returnToken;
break;
}
case '\t': case '\u000c': case ' ':
{
mWS(true);
theRetToken=_returnToken;
break;
}
case '.':
{
mDOT(true);
theRetToken=_returnToken;
break;
}
default:
if ((LA(1)=='/') && (LA(2)=='*') && (LA(3)=='*')) {
mSTART(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='*') && (LA(2)=='/') && (true)) {
mEND(true);
theRetToken=_returnToken;
}
else if ((_tokenSet_0.member(LA(1))) && (true) && (true)) {
mID(true);
theRetToken=_returnToken;
}
else {
if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
}
if ( _returnToken==null ) continue tryAgain; // found SKIP token
_ttype = _returnToken.getType();
_ttype = testLiteralsTable(_ttype);
_returnToken.setType(_ttype);
return _returnToken;
}
catch (RecognitionException e) {
throw new TokenStreamRecognitionException(e);
}
}
catch (CharStreamException cse) {
if ( cse instanceof CharStreamIOException ) {
throw new TokenStreamIOException(((CharStreamIOException)cse).io);
}
else {
throw new TokenStreamException(cse.getMessage());
}
}
}
}
public final void mSTART(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = START;
int _saveIndex;
match("/**");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mEND(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = END;
int _saveIndex;
match("*/");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mNL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NL;
int _saveIndex;
{
if ((LA(1)=='\r') && (LA(2)=='\n')) {
match("\r\n");
}
else if ((LA(1)=='\r') && (true)) {
match('\r');
}
else if ((LA(1)=='\n')) {
match('\n');
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
newline();
{
_loop24:
do {
if ((LA(1)=='\t'||LA(1)=='\u000c'||LA(1)==' ')) {
mWS(false);
}
else {
break _loop24;
}
} while (true);
}
{
_loop26:
do {
if (((LA(1)=='*'))&&(LA(2) != '/')) {
match('*');
}
else {
break _loop26;
}
} while (true);
}
text.setLength(_begin); text.append("\n");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS;
int _saveIndex;
{
switch ( LA(1)) {
case ' ':
{
match(' ');
break;
}
case '\t':
{
match('\t');
break;
}
case '\u000c':
{
match('\014');
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mDOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = DOT;
int _saveIndex;
match('.');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mID(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ID;
int _saveIndex;
{
int _cnt35=0;
_loop35:
do {
switch ( LA(1)) {
case '*':
{
{
if (!(LA(2) != '/'))
throw new SemanticException("LA(2) != '/'");
match('*');
}
break;
}
case '/':
{
{
if (!(LA(2) != '*' && LA(3) != '*'))
throw new SemanticException("LA(2) != '*' && LA(3) != '*'");
match('/');
}
break;
}
default:
if ((_tokenSet_1.member(LA(1)))) {
{
match(_tokenSet_1);
}
}
else {
if ( _cnt35>=1 ) { break _loop35; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
}
_cnt35++;
} while (true);
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
private static final long[] mk_tokenSet_0() {
long[] data = new long[8];
data[0]=-70373039158792L;
for (int i = 1; i<=3; i++) { data[i]=-1L; }
return data;
}
public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
private static final long[] mk_tokenSet_1() {
long[] data = new long[8];
data[0]=-215508574025224L;
for (int i = 1; i<=3; i++) { data[i]=-1L; }
return data;
}
public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?