Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antlr 3.4 error compiling to Java target #65

Closed
rajah9 opened this issue Aug 9, 2012 · 1 comment
Closed

Antlr 3.4 error compiling to Java target #65

rajah9 opened this issue Aug 9, 2012 · 1 comment

Comments

@rajah9
Copy link

rajah9 commented Aug 9, 2012

I am getting a Java compile error on a grammar.

I'm using Eclipse Indigo SR2 and these plugins:

  • ANTLR IDE- ANTLR Tools v 2.1.2.201108281759
  • ANTLR IDE- StringTemplate Tools, 1.1.0.201108281759

I am having Eclipse place the generated Java code in a package antlr-generated. The build path for antlr-generated includes antlr-3.4-complete.jar.

Here is my grammar:

/* Entry point */
 8: swiftMessage: block4 ;

10: block4: STARTBLOCK '4:' tag_value_pair+ ENDMESSAGEBLOCK ;

12: tag_value_pair :   NEWLINE tag value ;



16: tag :  COLON '1'..'9' '0'..'9' ('A'..'Z')?  ;

18: value :   COLON ('a'..'z' | 'A'..'Z' | '0'..'9' | ' ' | ',' | '.' )* ;

20: STARTBLOCK : '{' ;

22: ENDMESSAGEBLOCK : '-}' ;

24: NEWLINE : '\n' ;

26: COLON: ':' ; 

Here is the generated SwiftBugParser code (portions of comments ommitted):

    // $ANTLR start "tag"
    // \\SwiftBug.g:16:1: tag : COLON '1' .. '9' '0' .. '9' ( 'A' .. 'Z' )? ;
    public final void tag() throws RecognitionException {
        try {
            // \\SwiftBug.g:16:5: ( COLON '1' .. '9' '0' .. '9' ( 'A' .. 'Z' )? )
            // \\SwiftBug.g:16:8: COLON '1' .. '9' '0' .. '9' ( 'A' .. 'Z' )?
            {
            match(input,COLON,FOLLOW_COLON_in_tag68); 

            matchRange('1','9');  // FIRST ERROR, LINE 193

            matchRange('0','9');  // SECOND ERROR, LINE 195

            // \\SwiftBug.g:16:32: ( 'A' .. 'Z' )?
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( () ) {           // THIRD ERROR, LINE 201
                alt2=1;
            }
            switch (alt2) {
                case 1 :
                    // \\SwiftBug.g:
                    {
                    if (  ) {     // FOURTH ERROR, LINE 208
                        input.consume();
                        state.errorRecovery=false;
                    }
                    else {
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }


                    }
                    break;

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
            // do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "tag"

I am getting these four Java compilation errors:

Description Resource    Path    Location    Type
The method matchRange(char, char) is undefined for the type SwiftBugParser  SwiftBugParser.java /SwiftMessage/antlr-generated   line 193    Java Problem
The method matchRange(char, char) is undefined for the type SwiftBugParser  SwiftBugParser.java /SwiftMessage/antlr-generated   line 195    Java Problem
Syntax error on token "(", Expression expected after this token SwiftBugParser.java /SwiftMessage/antlr-generated   line 201    Java Problem
Syntax error on token "(", Expression expected after this token SwiftBugParser.java /SwiftMessage/antlr-generated   line 208    Java Problem
@sharwell
Copy link
Member

sharwell commented Aug 9, 2012

This repository is for ANTLR v4. I believe you are looking for antlr/antlr3.

@sharwell sharwell closed this as completed Aug 9, 2012
parrt pushed a commit that referenced this issue Jun 30, 2015
Include Windows Phone 8.1 support in PCL builds
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
…upport

mark `EMPTY_RULECTX` as `@SharedImmutable` for iOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants