// $ANTLR 2.7.4: "boolean.g" -> "BooleanAntlrLexer.java"$
package org.jostraca.util;
import java.io.InputStream;
import org.jostraca.comp.antlr.TokenStreamException;
import org.jostraca.comp.antlr.TokenStreamIOException;
import org.jostraca.comp.antlr.TokenStreamRecognitionException;
import org.jostraca.comp.antlr.CharStreamException;
import org.jostraca.comp.antlr.CharStreamIOException;
import org.jostraca.comp.antlr.ANTLRException;
import java.io.Reader;
import java.util.Hashtable;
import org.jostraca.comp.antlr.CharScanner;
import org.jostraca.comp.antlr.InputBuffer;
import org.jostraca.comp.antlr.ByteBuffer;
import org.jostraca.comp.antlr.CharBuffer;
import org.jostraca.comp.antlr.Token;
import org.jostraca.comp.antlr.CommonToken;
import org.jostraca.comp.antlr.RecognitionException;
import org.jostraca.comp.antlr.NoViableAltForCharException;
import org.jostraca.comp.antlr.MismatchedCharException;
import org.jostraca.comp.antlr.TokenStream;
import org.jostraca.comp.antlr.ANTLRHashString;
import org.jostraca.comp.antlr.LexerSharedInputState;
import org.jostraca.comp.antlr.collections.impl.BitSet;
import org.jostraca.comp.antlr.SemanticException;
public class BooleanAntlrLexer extends org.jostraca.comp.antlr.CharScanner implements BooleanAntlrLexerTokenTypes, TokenStream
{
public BooleanAntlrLexer(InputStream in) {
this(new ByteBuffer(in));
}
public BooleanAntlrLexer(Reader in) {
this(new CharBuffer(in));
}
public BooleanAntlrLexer(InputBuffer ib) {
this(new LexerSharedInputState(ib));
}
public BooleanAntlrLexer(LexerSharedInputState state) {
super(state);
caseSensitiveLiterals = true;
setCaseSensitive(false);
literals = new Hashtable();
}
public Token nextToken() throws TokenStreamException {
Token theRetToken=null;
tryAgain:
for (;;) {
Token _token = null;
int _ttype = Token.INVALID_TYPE;
setCommitToPath(false);
resetText();
try { // for char stream error handling
try { // for lexical error handling
switch ( LA(1)) {
case '1': case 't': case 'y':
{
mTRUE(true);
theRetToken=_returnToken;
break;
}
case '&': case '+': case ',': case 'a':
{
mAND(true);
theRetToken=_returnToken;
break;
}
case 'o': case '|':
{
mOR(true);
theRetToken=_returnToken;
break;
}
case '^': case 'x':
{
mXOR(true);
theRetToken=_returnToken;
break;
}
case '(':
{
mLP(true);
theRetToken=_returnToken;
break;
}
case ')':
{
mRP(true);
theRetToken=_returnToken;
break;
}
case '\t': case '\n': case '\r': case ' ':
{
mWS(true);
theRetToken=_returnToken;
break;
}
default:
if ((LA(1)=='0'||LA(1)=='f'||LA(1)=='n') && (true) && (true)) {
mFALSE(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='!'||LA(1)=='n'||LA(1)=='~') && (true) && (true)) {
mNOT(true);
theRetToken=_returnToken;
}
else {
if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
else {consume(); continue tryAgain;}
}
}
if ( _returnToken==null ) continue tryAgain; // found SKIP token
_ttype = _returnToken.getType();
_ttype = testLiteralsTable(_ttype);
_returnToken.setType(_ttype);
return _returnToken;
}
catch (RecognitionException e) {
if ( !getCommitToPath() ) {consume(); continue tryAgain;}
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 mTRUE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = TRUE;
int _saveIndex;
switch ( LA(1)) {
case 't':
{
match('t');
{
if ((LA(1)=='r')) {
match('r');
match('u');
match('e');
}
else {
}
}
break;
}
case 'y':
{
match('y');
{
if ((LA(1)=='e')) {
match('e');
match('s');
}
else {
}
}
break;
}
case '1':
{
match('1');
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 mFALSE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = FALSE;
int _saveIndex;
switch ( LA(1)) {
case 'f':
{
match('f');
{
if ((LA(1)=='a')) {
match('a');
match('l');
match('s');
match('e');
}
else {
}
}
break;
}
case 'n':
{
match('n');
{
if ((LA(1)=='o')) {
match('o');
}
else {
}
}
break;
}
case '0':
{
match('0');
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 mAND(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = AND;
int _saveIndex;
switch ( LA(1)) {
case ',':
{
match(',');
break;
}
case '+':
{
match('+');
break;
}
case 'a':
{
match('a');
match('n');
match('d');
break;
}
default:
if ((LA(1)=='&') && (LA(2)=='&')) {
match('&');
match('&');
}
else if ((LA(1)=='&') && (true)) {
match('&');
}
else {
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 mOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = OR;
int _saveIndex;
if ((LA(1)=='|') && (LA(2)=='|')) {
match('|');
match('|');
}
else if ((LA(1)=='|') && (true)) {
match('|');
}
else if ((LA(1)=='o')) {
match('o');
match('r');
}
else {
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 mXOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = XOR;
int _saveIndex;
if ((LA(1)=='^') && (LA(2)=='^')) {
match('^');
match('^');
}
else if ((LA(1)=='^') && (true)) {
match('^');
}
else if ((LA(1)=='x')) {
match('x');
match('o');
match('r');
}
else {
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 mNOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NOT;
int _saveIndex;
switch ( LA(1)) {
case '!':
{
match('!');
break;
}
case '~':
{
match('~');
break;
}
case 'n':
{
match('n');
match('o');
match('t');
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 mLP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = LP;
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 mRP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RP;
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 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 '\n':
{
match('\n');
break;
}
case '\r':
{
match('\r');
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
if ( inputState.guessing==0 ) {
_ttype = Token.SKIP;
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
}