[il-antlr-interest: 28869] [antlr-interest] Find X :-)

2010-05-18 Thread Sameh W. Zaky
Dear All, I have in my grammar: fragment UNIT_NAME :; ID : ('a'..'z'|'_')* { if ( myLookUpMethod( *X* ) ) $type=UNIT_NAME; } ; === Instead of *X*, I wanna refer to the text that is in red.. For example, the token w_aw_s is ID. I want to take the text of this token

[il-antlr-interest: 28870] Re: [antlr-interest] Find X :-)

2010-05-18 Thread Sameh W. Zaky
OK, Sorry for that! Just after I have sent this message I realized that the problem is that ANTLR cannot find my method myLookUpMethod.. I have defined it in @members{} part of the grammar file.. But ANTLR still cannot find it.. Any idea? On Tue, May 18, 2010 at 4:35 PM, Sameh W. Zaky

[il-antlr-interest: 28871] Re: [antlr-interest] Find X :-)

2010-05-18 Thread John B. Brodie
On Tue, 2010-05-18 at 17:10 +0200, Sameh W. Zaky wrote: OK, Sorry for that! Just after I have sent this message I realized that the problem is that ANTLR cannot find my method myLookUpMethod.. I have defined it in @members{} part of the grammar file.. But ANTLR still cannot find it.. Any

[il-antlr-interest: 28872] Re: [antlr-interest] ANTLR Two Simple Questions :-)

2010-05-18 Thread Jim Idle
Well, err the method inArray() is an imaginary method that you will write. It just needs to take a string and see if that string is currently something that should be a UNIT_NAME. If it is real simple then you could just use a standard List object of your choice. Please replay to the list

[il-antlr-interest: 28877] Re: [antlr-interest] Custom lexer and parser constructors

2010-05-18 Thread Bart Kiers
On Tue, May 18, 2010 at 6:04 PM, Cameron Ross cr...@kojeware.com wrote: Hi, Is there a way to define custom constructors for ANTLR lexers and parsers? Sure, you can create custom methods, c-tors and attributes in: @parser::members { // here } or @lexer::members { // here } Regards,

[il-antlr-interest: 28878] Re: [antlr-interest] Custom lexer and parser constructors

2010-05-18 Thread Jim Idle
OK - just add the reporter to the paresr members and create a setErrorReporter() method. Jim From: Cameron Ross [mailto:cr...@kojeware.com] Sent: Tuesday, May 18, 2010 9:19 AM To: Jim Idle Cc: antlr-interest@antlr.org Subject: Re: [antlr-interest] Custom lexer and parser constructors

[il-antlr-interest: 28881] Re: [antlr-interest] ANTLR Two Simple Questions :-)

2010-05-18 Thread Sameh W. Zaky
That was helpful, thanks :-) On Tue, May 18, 2010 at 5:31 PM, Jim Idle j...@temporal-wave.com wrote: Well, err the method inArray() is an imaginary method that you will write. It just needs to take a string and see if that string is currently something that should be a UNIT_NAME. If it is

[il-antlr-interest: 28882] [antlr-interest] enums in v4 ANTLR Java code generation considered useless

2010-05-18 Thread Terence Parr
A lot of you have wondered why I'd don't use enum types for token types in the generated Java-based parsers: enum TokenType { ID(3), INT(4) }; I gave it my best shot but once again I found that enums just don't seem to work for me. For example, without inheritance how can I define the match

[il-antlr-interest: 28885] Re: [antlr-interest] enums in v4 ANTLR Java code generation considered useless

2010-05-18 Thread Scott Stanchfield
There are several advantages to enums: * there is a discrete set of values that can be used (no accidental 42's passed in when 42 isn't a token type) * the enum value can carry extra information * the enum values can override methods differently OH - one of the things that's clouding this is that

[il-antlr-interest: 28886] Re: [antlr-interest] enums in v4 ANTLR Java code generation considered useless

2010-05-18 Thread Scott Stanchfield
A little clarification... Start with (as Edgar said) public interface TokenType { } public enum CommonTypes implements TokenType { EOF; // others? } public class Token { private TokenType type; public TokenType getType() {return type;} ... } public class Parser

[il-antlr-interest: 28887] [antlr-interest] help please

2010-05-18 Thread Ernesto Castillo
hello everybody my name is Ernesto and i am calling for help on antlr programming, i am a newby in this and i am in my second semester master , after 12 years ago that finish my degree in computer science but because the circumstance never work in the computer field, but planning to get