Hi Jim,

thanks for the reply.

I am still running into the same problem.

The grammer now is:


lexer grammar Simple;

options
{
language = Java;
}

@header
{
  package test;
}

fragment DOT_PROG: ;
fragment DOT_SL: ;
fragment DOT_PRINT: ;
fragment DOT_ADD: ;
fragment DOT_SPP: ;

DOT: '.'
  (
  ('PROG')=>'PROG' {$type=DOT_PROG;}
  |('SL')=>'SL' {$type=DOT_SL;}
  |('PRT')=>'PRT' {$type=DOT_PRINT;}
//  |('ADD')=>'ADD' {$type=DOT_ADD;}
  |('SPP')=>'SPP' {$type=DOT_SPP;}
  )?
  ;

WORD: ('A'..'Z')+;

given the input ".S" the lexing result is a token DOT and then a token 
WORD. But as soon as the comment is removed from the fourth alternative 
using the same input the result is "no viable alternative at character 
'<EOF>'"

I've read a bit through the generated lexer code. The major difference 
between the version that works and the version that fails seems to be 
that in the working version no "dfa.predict" call is used. I have no 
idea why the ANTLR generator in one case generates code that uses the 
DFA and in the other case generates code that doesn't use the DFAs. But 
all in all this complete behaviour seems to me like a serious bug in 
ANTLR. I've tried the same lexer grammar in JavaCC without any problems. 
Is there any way to work around this bug without having to write a lexer 
on my own?

Regards,
Thomas
> Thomas Woelfle wrote:
>> Hi,
>>
>> I've been running in an almost similar problem again.
>>
>> The subject language that has to be parsed defines some keywords which 
>> begin with a '.'. Besides that there are specific names allowed and '.' 
>> is allowed to be a token too.
>>
>> The reduced lexer grammar that produces the problem is:
>>
>> DOT: '.';
>>
>> ARG: ('.ARG')=> '.ARG';
>>
>> ATT: ('.ATT')=> '.ATT';
>>
>> NAME
>>   :
>>   ('A'..'Z')*;
>>
>>
>>   
> This token allows a match of an empty string and is going to cause all 
> sorts of problems. You want:
>
> NAME : ('A'..'Z')+;
>
> Then if you still have problems, either do:
>
> DOT : '.';
> ARG: 'ARG';
> ATT : 'ATT';
>
> ident : ID
>         | DOT (ARG|ATT)
>         ;
>
> Or:
>
> fragment ARG : ;  // Define token number and document
> fragment ATT : ; // Define token number and document
> DOT : '.'
>            (  ('ARG')=>'ARG'  { $type = ARG; }
>              | ('ATT')=>'ATT'    { $type = ATT; }
>            )
>     
>
> Jim
> ------------------------------------------------------------------------
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>   


-- 
Interactive Objects Software GmbH
Basler Strasse 61
79100 Freiburg, Germany

Phone:  +49 761 400 73 0
mailto:[email protected]


------------------------------------------------------------------------

Interactive Objects' Legacy Modernization Solutions 

Get Your Applications SOA-Ready!

See http://www.interactive-objects.com/ for more information.

------------------------------------------------------------------------


Interactive Objects Software GmbH | Freiburg | Geschäftsführer: Alberto 
Perandones, Andrea Hemprich
| AG Frbg. HRB 5810 | USt-ID: DE 197983057


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

// $ANTLR 3.1.1 test/Simple.g 2009-03-04 11:04:18

  package test;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
public class Simple extends Lexer {
    public static final int WORD=10;
    public static final int DOT_PRINT=6;
    public static final int DOT_SPP=8;
    public static final int DOT_ADD=7;
    public static final int DOT_SL=5;
    public static final int DOT_PROG=4;
    public static final int DOT=9;
    public static final int EOF=-1;

    // delegates
    // delegators

    public Simple() {;} 
    public Simple(CharStream input) {
        this(input, new RecognizerSharedState());
    }
    public Simple(CharStream input, RecognizerSharedState state) {
        super(input,state);

    }
    public String getGrammarFileName() { return "test/Simple.g"; }

    // $ANTLR start "DOT_PROG"
    public final void mDOT_PROG() throws RecognitionException {
        try {
            // test/Simple.g:13:18: ()
            // test/Simple.g:13:20: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_PROG"

    // $ANTLR start "DOT_SL"
    public final void mDOT_SL() throws RecognitionException {
        try {
            // test/Simple.g:14:16: ()
            // test/Simple.g:14:18: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_SL"

    // $ANTLR start "DOT_PRINT"
    public final void mDOT_PRINT() throws RecognitionException {
        try {
            // test/Simple.g:15:19: ()
            // test/Simple.g:15:21: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_PRINT"

    // $ANTLR start "DOT_ADD"
    public final void mDOT_ADD() throws RecognitionException {
        try {
            // test/Simple.g:16:17: ()
            // test/Simple.g:16:19: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_ADD"

    // $ANTLR start "DOT_SPP"
    public final void mDOT_SPP() throws RecognitionException {
        try {
            // test/Simple.g:17:17: ()
            // test/Simple.g:17:19: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_SPP"

    // $ANTLR start "DOT"
    public final void mDOT() throws RecognitionException {
        try {
            int _type = DOT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // test/Simple.g:19:4: ( '.' ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 
'SL' | ( 'PRT' )=> 'PRT' | ( 'SPP' )=> 'SPP' )? )
            // test/Simple.g:19:6: '.' ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 'SL' 
| ( 'PRT' )=> 'PRT' | ( 'SPP' )=> 'SPP' )?
            {
            match('.'); if (state.failed) return ;
            // test/Simple.g:20:3: ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 'SL' | ( 
'PRT' )=> 'PRT' | ( 'SPP' )=> 'SPP' )?
            int alt1=5;
            int LA1_0 = input.LA(1);

            if ( (LA1_0=='P') ) {
                int LA1_1 = input.LA(2);

                if ( (LA1_1=='R') ) {
                    int LA1_4 = input.LA(3);

                    if ( (LA1_4=='O') && (synpred1_Simple())) {
                        alt1=1;
                    }
                    else if ( (LA1_4=='T') && (synpred3_Simple())) {
                        alt1=3;
                    }
                }
            }
            else if ( (LA1_0=='S') ) {
                int LA1_2 = input.LA(2);

                if ( (LA1_2=='L') && (synpred2_Simple())) {
                    alt1=2;
                }
                else if ( (LA1_2=='P') && (synpred4_Simple())) {
                    alt1=4;
                }
            }
            switch (alt1) {
                case 1 :
                    // test/Simple.g:21:3: ( 'PROG' )=> 'PROG'
                    {
                    match("PROG"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_PROG;
                    }

                    }
                    break;
                case 2 :
                    // test/Simple.g:22:4: ( 'SL' )=> 'SL'
                    {
                    match("SL"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_SL;
                    }

                    }
                    break;
                case 3 :
                    // test/Simple.g:23:4: ( 'PRT' )=> 'PRT'
                    {
                    match("PRT"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_PRINT;
                    }

                    }
                    break;
                case 4 :
                    // test/Simple.g:25:4: ( 'SPP' )=> 'SPP'
                    {
                    match("SPP"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_SPP;
                    }

                    }
                    break;

            }


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
    // $ANTLR end "DOT"

    // $ANTLR start "WORD"
    public final void mWORD() throws RecognitionException {
        try {
            int _type = WORD;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // test/Simple.g:29:5: ( ( 'A' .. 'Z' )+ )
            // test/Simple.g:29:7: ( 'A' .. 'Z' )+
            {
            // test/Simple.g:29:7: ( 'A' .. 'Z' )+
            int cnt2=0;
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( ((LA2_0>='A' && LA2_0<='Z')) ) {
                    alt2=1;
                }


                switch (alt2) {
                case 1 :
                    // test/Simple.g:29:8: 'A' .. 'Z'
                    {
                    matchRange('A','Z'); if (state.failed) return ;

                    }
                    break;

                default :
                    if ( cnt2 >= 1 ) break loop2;
                    if (state.backtracking>0) {state.failed=true; return ;}
                        EarlyExitException eee =
                            new EarlyExitException(2, input);
                        throw eee;
                }
                cnt2++;
            } while (true);


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
    // $ANTLR end "WORD"

    public void mTokens() throws RecognitionException {
        // test/Simple.g:1:8: ( DOT | WORD )
        int alt3=2;
        int LA3_0 = input.LA(1);

        if ( (LA3_0=='.') ) {
            alt3=1;
        }
        else if ( ((LA3_0>='A' && LA3_0<='Z')) ) {
            alt3=2;
        }
        else {
            if (state.backtracking>0) {state.failed=true; return ;}
            NoViableAltException nvae =
                new NoViableAltException("", 3, 0, input);

            throw nvae;
        }
        switch (alt3) {
            case 1 :
                // test/Simple.g:1:10: DOT
                {
                mDOT(); if (state.failed) return ;

                }
                break;
            case 2 :
                // test/Simple.g:1:14: WORD
                {
                mWORD(); if (state.failed) return ;

                }
                break;

        }

    }

    // $ANTLR start synpred1_Simple
    public final void synpred1_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:21:3: ( 'PROG' )
        // test/Simple.g:21:4: 'PROG'
        {
        match("PROG"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred1_Simple

    // $ANTLR start synpred2_Simple
    public final void synpred2_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:22:4: ( 'SL' )
        // test/Simple.g:22:5: 'SL'
        {
        match("SL"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred2_Simple

    // $ANTLR start synpred3_Simple
    public final void synpred3_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:23:4: ( 'PRT' )
        // test/Simple.g:23:5: 'PRT'
        {
        match("PRT"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred3_Simple

    // $ANTLR start synpred4_Simple
    public final void synpred4_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:25:4: ( 'SPP' )
        // test/Simple.g:25:5: 'SPP'
        {
        match("SPP"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred4_Simple

    public final boolean synpred4_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred4_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }
    public final boolean synpred2_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred2_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }
    public final boolean synpred1_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred1_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }
    public final boolean synpred3_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred3_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }


 

}
// $ANTLR 3.1.1 test/Simple.g 2009-03-04 11:03:37

  package test;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
public class Simple extends Lexer {
    public static final int WORD=10;
    public static final int DOT_PRINT=6;
    public static final int DOT_SPP=8;
    public static final int DOT_ADD=7;
    public static final int DOT_SL=5;
    public static final int DOT_PROG=4;
    public static final int DOT=9;
    public static final int EOF=-1;

    // delegates
    // delegators

    public Simple() {;} 
    public Simple(CharStream input) {
        this(input, new RecognizerSharedState());
    }
    public Simple(CharStream input, RecognizerSharedState state) {
        super(input,state);

    }
    public String getGrammarFileName() { return "test/Simple.g"; }

    // $ANTLR start "DOT_PROG"
    public final void mDOT_PROG() throws RecognitionException {
        try {
            // test/Simple.g:13:18: ()
            // test/Simple.g:13:20: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_PROG"

    // $ANTLR start "DOT_SL"
    public final void mDOT_SL() throws RecognitionException {
        try {
            // test/Simple.g:14:16: ()
            // test/Simple.g:14:18: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_SL"

    // $ANTLR start "DOT_PRINT"
    public final void mDOT_PRINT() throws RecognitionException {
        try {
            // test/Simple.g:15:19: ()
            // test/Simple.g:15:21: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_PRINT"

    // $ANTLR start "DOT_ADD"
    public final void mDOT_ADD() throws RecognitionException {
        try {
            // test/Simple.g:16:17: ()
            // test/Simple.g:16:19: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_ADD"

    // $ANTLR start "DOT_SPP"
    public final void mDOT_SPP() throws RecognitionException {
        try {
            // test/Simple.g:17:17: ()
            // test/Simple.g:17:19: 
            {
            }

        }
        finally {
        }
    }
    // $ANTLR end "DOT_SPP"

    // $ANTLR start "DOT"
    public final void mDOT() throws RecognitionException {
        try {
            int _type = DOT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // test/Simple.g:19:4: ( '.' ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 
'SL' | ( 'PRT' )=> 'PRT' | ( 'ADD' )=> 'ADD' | ( 'SPP' )=> 'SPP' )? )
            // test/Simple.g:19:6: '.' ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 'SL' 
| ( 'PRT' )=> 'PRT' | ( 'ADD' )=> 'ADD' | ( 'SPP' )=> 'SPP' )?
            {
            match('.'); if (state.failed) return ;
            // test/Simple.g:20:3: ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 'SL' | ( 
'PRT' )=> 'PRT' | ( 'ADD' )=> 'ADD' | ( 'SPP' )=> 'SPP' )?
            int alt1=6;
            alt1 = dfa1.predict(input);
            switch (alt1) {
                case 1 :
                    // test/Simple.g:21:3: ( 'PROG' )=> 'PROG'
                    {
                    match("PROG"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_PROG;
                    }

                    }
                    break;
                case 2 :
                    // test/Simple.g:22:4: ( 'SL' )=> 'SL'
                    {
                    match("SL"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_SL;
                    }

                    }
                    break;
                case 3 :
                    // test/Simple.g:23:4: ( 'PRT' )=> 'PRT'
                    {
                    match("PRT"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_PRINT;
                    }

                    }
                    break;
                case 4 :
                    // test/Simple.g:24:4: ( 'ADD' )=> 'ADD'
                    {
                    match("ADD"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_ADD;
                    }

                    }
                    break;
                case 5 :
                    // test/Simple.g:25:4: ( 'SPP' )=> 'SPP'
                    {
                    match("SPP"); if (state.failed) return ;

                    if ( state.backtracking==0 ) {
                      _type=DOT_SPP;
                    }

                    }
                    break;

            }


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
    // $ANTLR end "DOT"

    // $ANTLR start "WORD"
    public final void mWORD() throws RecognitionException {
        try {
            int _type = WORD;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // test/Simple.g:29:5: ( ( 'A' .. 'Z' )+ )
            // test/Simple.g:29:7: ( 'A' .. 'Z' )+
            {
            // test/Simple.g:29:7: ( 'A' .. 'Z' )+
            int cnt2=0;
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( ((LA2_0>='A' && LA2_0<='Z')) ) {
                    alt2=1;
                }


                switch (alt2) {
                case 1 :
                    // test/Simple.g:29:8: 'A' .. 'Z'
                    {
                    matchRange('A','Z'); if (state.failed) return ;

                    }
                    break;

                default :
                    if ( cnt2 >= 1 ) break loop2;
                    if (state.backtracking>0) {state.failed=true; return ;}
                        EarlyExitException eee =
                            new EarlyExitException(2, input);
                        throw eee;
                }
                cnt2++;
            } while (true);


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
    // $ANTLR end "WORD"

    public void mTokens() throws RecognitionException {
        // test/Simple.g:1:8: ( DOT | WORD )
        int alt3=2;
        int LA3_0 = input.LA(1);

        if ( (LA3_0=='.') ) {
            alt3=1;
        }
        else if ( ((LA3_0>='A' && LA3_0<='Z')) ) {
            alt3=2;
        }
        else {
            if (state.backtracking>0) {state.failed=true; return ;}
            NoViableAltException nvae =
                new NoViableAltException("", 3, 0, input);

            throw nvae;
        }
        switch (alt3) {
            case 1 :
                // test/Simple.g:1:10: DOT
                {
                mDOT(); if (state.failed) return ;

                }
                break;
            case 2 :
                // test/Simple.g:1:14: WORD
                {
                mWORD(); if (state.failed) return ;

                }
                break;

        }

    }

    // $ANTLR start synpred1_Simple
    public final void synpred1_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:21:3: ( 'PROG' )
        // test/Simple.g:21:4: 'PROG'
        {
        match("PROG"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred1_Simple

    // $ANTLR start synpred2_Simple
    public final void synpred2_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:22:4: ( 'SL' )
        // test/Simple.g:22:5: 'SL'
        {
        match("SL"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred2_Simple

    // $ANTLR start synpred3_Simple
    public final void synpred3_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:23:4: ( 'PRT' )
        // test/Simple.g:23:5: 'PRT'
        {
        match("PRT"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred3_Simple

    // $ANTLR start synpred4_Simple
    public final void synpred4_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:24:4: ( 'ADD' )
        // test/Simple.g:24:5: 'ADD'
        {
        match("ADD"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred4_Simple

    // $ANTLR start synpred5_Simple
    public final void synpred5_Simple_fragment() throws RecognitionException {  
 
        // test/Simple.g:25:4: ( 'SPP' )
        // test/Simple.g:25:5: 'SPP'
        {
        match("SPP"); if (state.failed) return ;


        }
    }
    // $ANTLR end synpred5_Simple

    public final boolean synpred5_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred5_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }
    public final boolean synpred4_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred4_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }
    public final boolean synpred2_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred2_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }
    public final boolean synpred1_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred1_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }
    public final boolean synpred3_Simple() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred3_Simple_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }


    protected DFA1 dfa1 = new DFA1(this);
    static final String DFA1_eotS =
        "\1\4\11\uffff";
    static final String DFA1_eofS =
        "\12\uffff";
    static final String DFA1_minS =
        "\1\101\1\122\1\114\2\uffff\1\117\4\uffff";
    static final String DFA1_maxS =
        "\1\123\1\122\1\120\2\uffff\1\124\4\uffff";
    static final String DFA1_acceptS =
        "\3\uffff\1\4\1\6\1\uffff\1\2\1\5\1\1\1\3";
    static final String DFA1_specialS =
        "\1\2\1\uffff\1\1\2\uffff\1\0\4\uffff}>";
    static final String[] DFA1_transitionS = {
            "\1\3\16\uffff\1\1\2\uffff\1\2",
            "\1\5",
            "\1\6\3\uffff\1\7",
            "",
            "",
            "\1\10\4\uffff\1\11",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA1_eot = DFA.unpackEncodedString(DFA1_eotS);
    static final short[] DFA1_eof = DFA.unpackEncodedString(DFA1_eofS);
    static final char[] DFA1_min = 
DFA.unpackEncodedStringToUnsignedChars(DFA1_minS);
    static final char[] DFA1_max = 
DFA.unpackEncodedStringToUnsignedChars(DFA1_maxS);
    static final short[] DFA1_accept = DFA.unpackEncodedString(DFA1_acceptS);
    static final short[] DFA1_special = DFA.unpackEncodedString(DFA1_specialS);
    static final short[][] DFA1_transition;

    static {
        int numStates = DFA1_transitionS.length;
        DFA1_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA1_transition[i] = DFA.unpackEncodedString(DFA1_transitionS[i]);
        }
    }

    class DFA1 extends DFA {

        public DFA1(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 1;
            this.eot = DFA1_eot;
            this.eof = DFA1_eof;
            this.min = DFA1_min;
            this.max = DFA1_max;
            this.accept = DFA1_accept;
            this.special = DFA1_special;
            this.transition = DFA1_transition;
        }
        public String getDescription() {
            return "20:3: ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 'SL' | ( 'PRT' )=> 
'PRT' | ( 'ADD' )=> 'ADD' | ( 'SPP' )=> 'SPP' )?";
        }
        public int specialStateTransition(int s, IntStream _input) throws 
NoViableAltException {
            IntStream input = _input;
                int _s = s;
            switch ( s ) {
                    case 0 : 
                        int LA1_5 = input.LA(1);

                         
                        int index1_5 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (LA1_5=='O') && (synpred1_Simple())) {s = 8;}

                        else if ( (LA1_5=='T') && (synpred3_Simple())) {s = 9;}

                         
                        input.seek(index1_5);
                        if ( s>=0 ) return s;
                        break;
                    case 1 : 
                        int LA1_2 = input.LA(1);

                         
                        int index1_2 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (LA1_2=='L') && (synpred2_Simple())) {s = 6;}

                        else if ( (LA1_2=='P') && (synpred5_Simple())) {s = 7;}

                         
                        input.seek(index1_2);
                        if ( s>=0 ) return s;
                        break;
                    case 2 : 
                        int LA1_0 = input.LA(1);

                         
                        int index1_0 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (LA1_0=='P') ) {s = 1;}

                        else if ( (LA1_0=='S') ) {s = 2;}

                        else if ( (LA1_0=='A') && (synpred4_Simple())) {s = 3;}

                        else s = 4;

                         
                        input.seek(index1_0);
                        if ( s>=0 ) return s;
                        break;
            }
            if (state.backtracking>0) {state.failed=true; return -1;}
            NoViableAltException nvae =
                new NoViableAltException(getDescription(), 1, _s, input);
            error(nvae);
            throw nvae;
        }
    }
 

}
package test;

import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;

public class Main
{
        public static void main(final String[] args) throws RecognitionException
        {
                final Simple lexer = new Simple(new ANTLRStringStream(".S"));
                final CommonTokenStream stream = new CommonTokenStream(lexer);
                for(final Object token : stream.getTokens())
                {
                        System.out.println(token);
                }
        }
}
lexer grammar Simple;

options
{
language = Java;
}

@header
{
  package test;
}

fragment DOT_PROG: ;
fragment DOT_SL: ;
fragment DOT_PRINT: ;
fragment DOT_ADD: ;
fragment DOT_SPP: ;

DOT: '.'
  (
  ('PROG')=>'PROG' {$type=DOT_PROG;}
  |('SL')=>'SL' {$type=DOT_SL;}
  |('PRT')=>'PRT' {$type=DOT_PRINT;}
//  |('ADD')=>'ADD' {$type=DOT_ADD;}
  |('SPP')=>'SPP' {$type=DOT_SPP;}
  )?
  ;

WORD: ('A'..'Z')+;
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to