Hello!

I'm studying capabilities of ANTLR, building very simple grammar. In my
tests, ANTLRWorks says in debug about UnwantedTokenException(found=null) at
rule:
        interface_decl
                :       INTERFACE ID '{' interface_parts '}'
                ;


It recognizes INTERFACE token and ID, consumes whitespace before curly
bracket, but fails to recongnize bracket. I'm completely confused with this.
Grammar and debug input follows.

Can anyone tell me what is mistake?

Andrey

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

grammar BppIDL;

tokens {
        INTERFACE='interface';
}

specification:
        interface_decl
;

header_decl     :
                '[' 'uuid' '(' UUID ')' ','
                'version' '(' '1.0' ')' ','
                'pointer_default' '(' 'unique' ')'
                ']'
        ;

interface_decl
        :       INTERFACE ID '{' interface_parts '}'
        ;

interface_parts
        :       interface_part*
        ;

interface_part
        :       typedef_decl
        |       include_decl
        |       operation_decl
        ;

include_decl    :
        '#' 'include' STRING_LITERAL '\n'
        ;

typedef_decl    :
        'typedef' type_decl call_modifier? ID ';'
        ;

type_decl       :
        ID '*'*
        ;

call_modifier
        : '_stdcall'
        ;

operation_decl
        :
                type_decl ID operation_parameters ';'
        ;

operation_parameters
        :       '(' operation_parameter ( ',' operation_parameter )* ')'
        |       '(' ')'
        ;

operation_parameter
        : type_decl ID
        ;

ID  :   ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
    ;

INT :   '0'..'9'+
    ;

WS
        :       (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;}
        ;

COMMENT
        :       '/*' ( options {greedy=false;} : . )* '*/'
{$channel=HIDDEN;}
        ;
        
LINE_COMMENT
        :       '//' ~('\n'|'\r')* '\r'? ('\n'|EOF) {$channel=HIDDEN;}
        ;

fragment
HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;

UUID    
        :       HEX_DIGIT+ '-' HEX_DIGIT+  '-' HEX_DIGIT+ '-' HEX_DIGIT+ '-'
HEX_DIGIT+ ;

STRING_LITERAL
        :       '"' ( ~('"') )* '"'
        ;

--------------------------
Test file is:
interface Server32rpc
        {
                typedef error_status_t _stdcall  RPCALL;
                typedef const char * BPP_USERID;
                typedef unsigned int * BPP_RCODE;

                #include "..\Bank32flds.h"
                #include "..\Bank32stru.h"
        

    RPCALL IsServerListening ();
}


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--

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.


Reply via email to