// $ANTLR : "grammar.g" -> "ExpressionParser.java"$
package model;
import antlr.ASTFactory;
import antlr.ASTPair;
import antlr.NoViableAltException;
import antlr.ParserSharedInputState;
import antlr.RecognitionException;
import antlr.TokenBuffer;
import antlr.TokenStream;
import antlr.TokenStreamException;
import antlr.collections.AST;
import antlr.collections.impl.BitSet;
public class ExpressionParser extends antlr.LLkParser implements ExpressionLexerTokenTypes
{
protected ExpressionParser(TokenBuffer tokenBuf, int k) {
super(tokenBuf,k);
tokenNames = _tokenNames;
buildTokenTypeASTClassMap();
astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}
public ExpressionParser(TokenBuffer tokenBuf) {
this(tokenBuf,1);
}
protected ExpressionParser(TokenStream lexer, int k) {
super(lexer,k);
tokenNames = _tokenNames;
buildTokenTypeASTClassMap();
astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}
public ExpressionParser(TokenStream lexer) {
this(lexer,1);
}
public ExpressionParser(ParserSharedInputState state) {
super(state,1);
tokenNames = _tokenNames;
buildTokenTypeASTClassMap();
astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}
public final void regular_expression() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST regular_expression_AST = null;
try { // for error handling
{
_loop27:
do {
if ((_tokenSet_0.member(LA(1)))) {
expr();
astFactory.addASTChild(currentAST, returnAST);
}
else if ((LA(1)==LBRACKET)) {
group();
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop27;
}
} while (true);
}
regular_expression_AST = (AST)currentAST.root;
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_1);
}
returnAST = regular_expression_AST;
}
public final void expr() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST expr_AST = null;
try { // for error handling
switch ( LA(1)) {
case LBRACKET:
{
group();
astFactory.addASTChild(currentAST, returnAST);
expr_AST = (AST)currentAST.root;
break;
}
case LHOOK:
{
range();
astFactory.addASTChild(currentAST, returnAST);
expr_AST = (AST)currentAST.root;
break;
}
case INT:
case CHARL:
case CHARU:
{
any();
astFactory.addASTChild(currentAST, returnAST);
expr_AST = (AST)currentAST.root;
break;
}
default:
if (((LA(1) >= BS && LA(1) <= DOLLAR))) {
special();
astFactory.addASTChild(currentAST, returnAST);
expr_AST = (AST)currentAST.root;
}
else if ((LA(1)==BS)) {
bs();
astFactory.addASTChild(currentAST, returnAST);
expr_AST = (AST)currentAST.root;
}
else {
throw new NoViableAltException(LT(1), getFilename());
}
}
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_2);
}
returnAST = expr_AST;
}
public final void group() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST group_AST = null;
try { // for error handling
AST tmp1_AST = null;
tmp1_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp1_AST);
match(LBRACKET);
{
_loop30:
do {
if ((_tokenSet_0.member(LA(1)))) {
expr();
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop30;
}
} while (true);
}
match(RBRACKET);
group_AST = (AST)currentAST.root;
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_2);
}
returnAST = group_AST;
}
public final void range() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST range_AST = null;
try { // for error handling
AST tmp3_AST = null;
tmp3_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp3_AST);
match(LHOOK);
ens();
astFactory.addASTChild(currentAST, returnAST);
match(RHOOK);
{
if ((_tokenSet_3.member(LA(1)))) {
quantifier();
astFactory.addASTChild(currentAST, returnAST);
}
else if ((_tokenSet_2.member(LA(1)))) {
}
else {
throw new NoViableAltException(LT(1), getFilename());
}
}
range_AST = (AST)currentAST.root;
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_2);
}
returnAST = range_AST;
}
public final void special() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST special_AST = null;
try { // for error handling
special_char();
astFactory.addASTChild(currentAST, returnAST);
any();
astFactory.addASTChild(currentAST, returnAST);
{
if ((_tokenSet_3.member(LA(1)))) {
quantifier();
astFactory.addASTChild(currentAST, returnAST);
}
else if ((_tokenSet_2.member(LA(1)))) {
}
else {
throw new NoViableAltException(LT(1), getFilename());
}
}
special_AST = (AST)currentAST.root;
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_2);
}
returnAST = special_AST;
}
public final void bs() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST bs_AST = null;
try { // for error handling
AST tmp5_AST = null;
tmp5_AST = astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp5_AST);
match(BS);
{
switch ( LA(1)) {
case BS:
{
AST tmp6_AST = null;
tmp6_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp6_AST);
match(BS);
break;
}
case QTE:
{
AST tmp7_AST = null;
tmp7_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp7_AST);
match(QTE);
break;
}
case DQTE:
{
AST tmp8_AST = null;
tmp8_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp8_AST);
match(DQTE);
break;
}
case NO:
{
AST tmp9_AST = null;
tmp9_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp9_AST);
match(NO);
break;
}
case INT:
case CHARL:
case CHARU:
{
any();
astFactory.addASTChild(currentAST, returnAST);
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
bs_AST = (AST)currentAST.root;
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_4);
}
returnAST = bs_AST;
}
public final void any() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST any_AST = null;
try { // for error handling
switch ( LA(1)) {
case CHARL:
{
AST tmp10_AST = null;
tmp10_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp10_AST);
match(CHARL);
any_AST = (AST)currentAST.root;
break;
}
case CHARU:
{
AST tmp11_AST = null;
tmp11_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp11_AST);
match(CHARU);
any_AST = (AST)currentAST.root;
break;
}
case INT:
{
AST tmp12_AST = null;
tmp12_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp12_AST);
match(INT);
any_AST = (AST)currentAST.root;
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_5);
}
returnAST = any_AST;
}
public final void ens() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST ens_AST = null;
try { // for error handling
{
switch ( LA(1)) {
case NO:
{
AST tmp13_AST = null;
tmp13_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp13_AST);
match(NO);
break;
}
case BS:
case INT:
case CHARL:
case CHARU:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
int _cnt38=0;
_loop38:
do {
switch ( LA(1)) {
case INT:
case CHARL:
case CHARU:
{
{
any();
astFactory.addASTChild(currentAST, returnAST);
AST tmp14_AST = null;
tmp14_AST = astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp14_AST);
match(MINUS);
any();
astFactory.addASTChild(currentAST, returnAST);
}
break;
}
case BS:
{
bs();
astFactory.addASTChild(currentAST, returnAST);
break;
}
default:
{
if ( _cnt38>=1 ) { break _loop38; } else {throw new NoViableAltException(LT(1), getFilename());}
}
}
_cnt38++;
} while (true);
}
ens_AST = (AST)currentAST.root;
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_6);
}
returnAST = ens_AST;
}
public final void quantifier() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST quantifier_AST = null;
try { // for error handling
switch ( LA(1)) {
case LBRACE:
{
{
AST tmp15_AST = null;
tmp15_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp15_AST);
match(LBRACE);
AST tmp16_AST = null;
tmp16_AST = astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp16_AST);
match(INT);
match(COMMA);
AST tmp18_AST = null;
tmp18_AST = astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp18_AST);
match(INT);
match(RBRACE);
}
quantifier_AST = (AST)currentAST.root;
break;
}
case STAR:
{
AST tmp20_AST = null;
tmp20_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp20_AST);
match(STAR);
quantifier_AST = (AST)currentAST.root;
break;
}
case PLUS:
{
AST tmp21_AST = null;
tmp21_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp21_AST);
match(PLUS);
quantifier_AST = (AST)currentAST.root;
break;
}
case QM:
{
AST tmp22_AST = null;
tmp22_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp22_AST);
match(QM);
quantifier_AST = (AST)currentAST.root;
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_2);
}
returnAST = quantifier_AST;
}
public final void special_char() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST special_char_AST = null;
try { // for error handling
switch ( LA(1)) {
case BS:
{
AST tmp23_AST = null;
tmp23_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp23_AST);
match(BS);
special_char_AST = (AST)currentAST.root;
break;
}
case NO:
{
AST tmp24_AST = null;
tmp24_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp24_AST);
match(NO);
special_char_AST = (AST)currentAST.root;
break;
}
case QM:
{
AST tmp25_AST = null;
tmp25_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp25_AST);
match(QM);
special_char_AST = (AST)currentAST.root;
break;
}
case DOLLAR:
{
AST tmp26_AST = null;
tmp26_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp26_AST);
match(DOLLAR);
special_char_AST = (AST)currentAST.root;
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
catch (RecognitionException ex) {
reportError(ex);
recover(ex,_tokenSet_7);
}
returnAST = special_char_AST;
}
public static final String[] _tokenNames = {
"<0>",
"EOF",
"<2>",
"NULL_TREE_LOOKAHEAD",
"PLUS",
"STAR",
"LBRACKET",
"RBRACKET",
"LBRACE",
"RBRACE",
"LHOOK",
"RHOOK",
"MINUS",
"BS",
"NO",
"QM",
"DOLLAR",
"COMMA",
"QTE",
"DQTE",
"DIGIT",
"INT",
"WS",
"CHARL",
"CHARU"
};
protected void buildTokenTypeASTClassMap() {
tokenTypeToASTClassMap=null;
};
private static final long[] mk_tokenSet_0() {
long[] data = { 27386944L, 0L};
return data;
}
public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
private static final long[] mk_tokenSet_1() {
long[] data = { 2L, 0L};
return data;
}
public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
private static final long[] mk_tokenSet_2() {
long[] data = { 27387074L, 0L};
return data;
}
public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
private static final long[] mk_tokenSet_3() {
long[] data = { 33072L, 0L};
return data;
}
public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
private static final long[] mk_tokenSet_4() {
long[] data = { 27389122L, 0L};
return data;
}
public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
private static final long[] mk_tokenSet_5() {
long[] data = { 27393522L, 0L};
return data;
}
public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5());
private static final long[] mk_tokenSet_6() {
long[] data = { 2048L, 0L};
return data;
}
public static final BitSet _tokenSet_6 = new BitSet(mk_tokenSet_6());
private static final long[] mk_tokenSet_7() {
long[] data = { 27262976L, 0L};
return data;
}
public static final BitSet _tokenSet_7 = new BitSet(mk_tokenSet_7());
}