thanks a lot, yet there still have a minor problem in my project, when I am
trying to get a return value from the program, I called in the main
function,but  I cannot find get the return value, does anybody see problem
in my grammar?

here it is:
num    returns [String t]
        :n = Num  {$t =
$n.getText();}|b64=Base64Block{$t=$b64.getText();}|ident=Id{$t=$ident.getText();}
        ;
Num   :     ( '0'..'9' ) * ;
Id   :     ( 'a'..'z' | 'A'..'Z' | '_' ) ( 'a'..'z' | 'A'..'Z' | '_' |'-'|
'0'..'9' ) *;
Base64Block  :('a'..'z'| 'A'..'Z'|'0'..'9'|'/'|'+'|'=')*;
the input is perfectly matched by the antlr and the program and can be
printed out correctly, but when i called like this  :
"System.out.println(parser.num());" , there is not any return value(there
should be some value in the num cause i put it in the input file), does
anybody know where my problem is?
thank you!

Su
2008/11/23 Kevin J. Cummings <[EMAIL PROTECTED]>

> Su Zhang wrote:
>
>> Hi all,
>> I encountered a very strange problem. I put a string 'read' in the grammar
>> code, and when matching, I would like the input to match the toke ID which
>> is defined as ('a'..'z'). Obviously, the IDshould match read, but why it
>> cannot match, just becasue I have a hardcoded string 'read' in the grammar?
>> does everyone know how can i get ride of this trouble?
>>
>
> Keywords vs reserved words.  Literals in the parser are reserved words.  If
> you wish for them to match identifiers, you must create a parser rule for
> identifier which includes both IDENTIFIER and the literals.
>
> Thank you!
>> Su
>>
>
> --
> Kevin J. Cummings
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> Registered Linux User #1232 (http://counter.li.org)
>



-- 
Su Zhang
PHD Candidate
Computer Information and Science
Kansas State University

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

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

Reply via email to