[il-antlr-interest: 33148] Re: [antlr-interest] antlrv3ide question

2011-07-13 Thread Gary Miller
Hey Bill,

It doesn't seem to be on the official wiki command line page (I though
I remembered it there, but..) the -make options should do the trick.

http://www.antlr.org/wiki/display/ANTLR3/Command+line+options
http://www.antlr.org/wiki/display/ANTLR3/How+to+use+ant+with+ANTLR3

Regards
Gary

On Wed, Jul 13, 2011 at 3:07 AM, Bill Andersen wrote:

> Folks
>
> I have a split lexer / parser grammar.  The lexer compiles and is working
> fine.  Changing the parser, however, causes recompilation of the lexer -
> this takes more time than I want.  Any good way to shut that off?
>
> Thanks
>
>.bill
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33149] Re: [antlr-interest] RES: RES: COBOL grammar

2011-07-13 Thread George S. Cowan
Nilo,

I'm an old COBOL hacker from way back, so I understand COBOL periods,
although I don't know what version of the COBOL standards that your compiler
is using.

I think the way to solve the problem with periods is to make it optional for
every statement. Then, right after a new paragraph header is encountered,
check the previous token to make sure that it is a period. Try the
validating semantic predicate

  { ((Token)input.LT(-1)).getText().equals(".") }?

(Does anyone know a simpler way to do that?)

George
 

> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Nilo Roberto C Paim
> Sent: Monday, July 11, 2011 6:39 PM
> To: 'Ron Burk'
> Cc: antlr-interest@antlr.org
> Subject: [antlr-interest] RES: RES: COBOL grammar
> 
> Hi, Ron.
> 
> Glad to say that I'm the maintainer of TinyCobol.
> 
> What I'm trying to do here is write a new version of it, using Antlr.
> In
> this new version, I want to implement a lot of things that does not
> exists
> today, like native GUI and native access to RDBMS in general. Also, I'm
> going to generate 'executables' for Java JVM and for .Net CIL. Current
> TinyCobol generates assembly code for 32 bits only, and I think this is
> a
> big limitation for it now.
> 
> But let's go to the real problem...
> 
> A command in Cobol may or may be not terminated by '.'. All sequence of
> commands terminated by only one '.' are a block. A sample of this are
> the
> commands in the 'then' or the 'else' part of an 'IF' command. In this
> case,
> the first '.' found on the end of some command terminates not only the
> command, but the 'IF' command as a whole.
> 
> Additionally, a '.' must be the last token between paragraphs. Alias,
> the
> command sequence on a paragraph needs only the final '.', if I want.
> 
> There is no way I could say if a '.' belongs to the preceding command
> or if
> it enclosing the current paragraph, except by the fact that, if the
> following token is a section name or a new paragraph, it quits the
> current
> paragraph; else it quits a block.
> 
> Maybe I'm just missing the way to say that to Antlr. As I've already
> said,
> I'm a newbie.
> 
> Thanks for interest and sorry the poor English. I'm Portuguese native
> speaker.
> 
> Nilo - Brazil
> 
> -Mensagem original-
> De: antlr-interest-boun...@antlr.org
> [mailto:antlr-interest-boun...@antlr.org] Em nome de Ron Burk
> Enviada em: segunda-feira, 11 de julho de 2011 19:24
> Cc: antlr-interest@antlr.org
> Assunto: Re: [antlr-interest] RES: COBOL grammar
> 
> > What else am I missing?
> 
> Are you certain you mean the '.' at the end of the command
> to be optional? An initial scan seems to indicate only one
> optional '.' in the tinyCobol grammar, in procedure declarations.
> 
> Likewise, an uneducated glance at another COBOL grammar:
> http://www.cs.vu.nl/grammarware/browsable/cobol/#EBNF
> seemed to indicate the "." is rarely optional.
> 
> Or put another way, at the end of a command, what are
> the precise rules for deciding whether a '.' belongs to
> the current command or to the enclosing paragraph?
> If you can state an unambiguous rule for making that decision,
> you can probably force ANTLR to do it.
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33150] Re: [antlr-interest] RES: COBOL grammar

2011-07-13 Thread George S. Cowan
Nilo,

OK, I've found a message with your grammar and here's another suggestion. 

Drop the optional period after a command so that a period always ends a
block. (Later, when you include building your AST, you must make sure that
your AST correctly ends an if-statement at the end of a block.) I think you
also want to require a block to contain a by using a + instead of an *. And
you will still need to check for the preceding period when a paragraph
begins. So here is a suggested direction for your grammar (untested).


grammar Cobol;

options {
 language = Java;
}

program : 'procedure' 'division' '.' section*;

section : ID 'section' '.' paragraph*;

paragraph : ID { ((Token)input.LT(-1)).getText().equals(".") }? '.' block* ;

block : command+ '.' ;

command: (cmdA | cmdB | cmdC ) ;

cmdA: 'A';

cmdB: 'B';

cmdC: 'C';

fragment Digit : '0'..'9';

fragment Letter : ('a'..'z' | 'A'..'Z');

ID : Letter ( Letter | Digit | '-' )*;

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

Good luck,
George

> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Nilo Roberto C Paim
> Sent: Monday, July 11, 2011 4:46 PM
> To: 'Parsiad Azimzadeh'; antlr-interest@antlr.org
> Subject: [antlr-interest] RES: COBOL grammar
> 
> Thanks, Parsiad, for your help.
> 
> Indeed the ambiguities are 'solved'... but using your solution, only
> the
> first 'command' of the first 'block' of the first 'paragraph' are
> parsed!
> 
> And I don't have something I can call 'END_BLOCK', as you suggested.
> This
> thing would be a '.', that can be preceded by a 'command' either... and
> the
> problem returns...
> 
> What else am I missing?
> 
> TIA,
> Nilo - Brazil
> 
> -Mensagem original-
> De: antlr-interest-boun...@antlr.org
> [mailto:antlr-interest-boun...@antlr.org] Em nome de Parsiad Azimzadeh
> Enviada em: segunda-feira, 11 de julho de 2011 14:36
> Para: antlr-interest@antlr.org
> Assunto: Re: [antlr-interest] COBOL grammar
> 
> Hi Nilo,
> 
> The problem is that a paragraph contains any number of blocks and a
> block
> contains any number of commands (the ambiguity here is that some
> paragraph
> with two commands can be perceived as containing either two blocks each
> with
> one command or a single block with two commands).
> 
> The fix is simple, remove the * symbol from the line:
> paragraph : ID '.' block* '.';
> 
> If multiple blocks holds semantic value, you might need to use a symbol
> to
> denote the end of a block. For example, instead of using the fix above
> you
> could change the block rule to:
> 
> block: (command END_BLOCK)*;
> 
> --
> Parsiad Azimzadeh
> http://sfu.ca/~paa4
> 
> On Mon, Jul 11, 2011 at 9:46 AM, Nilo Roberto C Paim
> wrote:
> 
> > Hi all,
> >
> > I'm facing a problem on my grammar that I don't know how to solve
> > (Antlr3.3)...
> >
> > Let me show you my grammar. Simplified, of course. It's just to show
> you
> my
> > trouble.
> >
> >
> >
> >
> >
> > grammar Cobol;
> >
> > options {
> >  language = Java;
> > }
> >
> > program : 'procedure' 'division' '.' section*;
> >
> > section : ID 'section' '.' paragraph*;
> >
> > paragraph : ID '.' block* '.';
> >
> > block : command*;
> >
> > command: (cmdA | cmdB | cmdC ) '.'?;
> >
> > cmdA: 'A';
> >
> > cmdB: 'B';
> >
> > cmdC: 'C';
> >
> > fragment Digit : '0'..'9';
> >
> > fragment Letter : ('a'..'z' | 'A'..'Z');
> >
> > ID : Letter ( Letter | Digit | '-' )*;
> >
> >
> >
> >
> >
> > Using this grammar, I'm having the following errors and warnings:
> >
> > warning(200): /Cobol/src/Cobol.g:14:12: Decision can match input such
> as
> > "{'.', 'A'..'C'}" using multiple alternatives: 1, 2
> > As a result, alternative(s) 2 were disabled for that input
> >  |---> ID '.' block* '.';
> >
> > error(201): /Cobol/src/Cobol.g:14:12: The following alternatives can
> never
> > be matched: 2
> >  |---> ID '.' block* '.';
> >
> > warning(200): /Cobol/src/Cobol.g:17:5: Decision can match input such
> as
> > "'B'" using multiple alternatives: 1, 2
> > As a result, alternative(s) 2 were disabled for that input
> >  |---> command*;
> >
> > warning(200): /Cobol/src/Cobol.g:17:5: Decision can match input such
> as
> > "'A'" using multiple alternatives: 1, 2
> > As a result, alternative(s) 2 were disabled for that input
> >  |---> command*;
> >
> > warning(200): /Cobol/src/Cobol.g:17:5: Decision can match input such
> as
> > "'C'" using multiple alternatives: 1, 2
> > As a result, alternative(s) 2 were disabled for that input
> >  |---> command*;
> >
> >
> > 4 warnings
> >
> > 1 error
> >
> > BUILD FAIL
> >
> >
> >
> > My real problem is:
> >
> > 1) any 'command' can be followed by a '.'
> > 2) any sequence of 'command's not followed by '.' forms a 'block'
> > 3) wherever I can use a 'command', I can use a 'block'
> > 4) the '.' signifies the end of a 'block'
> > 5) I can use any number of 'block's to form a 'parag

[il-antlr-interest: 33151] Re: [antlr-interest] Tree pattern won't rewrite AST C#

2011-07-13 Thread Sam Harwell
In your partial class file that accompanies your grammar, you should add the
following function override:

partial class MyTreeParser {
public override IAstRuleReturnScope Bottomup() { return bottomup(); }
}

Sam

-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of DJB MASTER
Sent: Tuesday, July 12, 2011 10:38 PM
To: antlr-interest@antlr.org
Subject: [antlr-interest] Tree pattern won't rewrite AST C#

Hey, I'm trying to apply simple tree patterns that can remove redundancy in
multiplication expressions, such as x*0 -> 0. However I can't get it to
rewrite my AST I feed in.

I'm using again >>>
http://media.pragprog.com/titles/tpdsl/code/IR/Vec/VecMathAST.g 

and I'm using this as my simplifier >>
http://media.pragprog.com/titles/tpdsl/code/walking/patterns/Simplify.g.

I'm getting a correct AST because it's identical to what Terrance gets in
the LP book.

I'm using this code to call my simplifier...

CommonTree AST = (CommonTree)parser.statlist().Tree;

CommonTreeNodeStream nodes = new CommonTreeNodeStream(AST);
nodes.TokenStream = tokens;

Simplifier simplifier = new Simplifier(nodes); CommonTree AST =
(CommonTree)simplifier.Downup(AST, true);

But it seems to do nothing.

--
View this message in context:
http://antlr.1301665.n2.nabble.com/Tree-pattern-won-t-rewrite-AST-C-tp657761
4p6577614.html
Sent from the ANTLR mailing list archive at Nabble.com.

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


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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33156] [antlr-interest] Two issues.

2011-07-13 Thread Steven Kibler
Is there an example of how to request tokens and their information (type,
value, text, etc) from the scanner?   If there is, where?

 

Is there an example of how to feed information into the scanner with other
than a file (a function call)?  By preprocessing the input, I can remove
over 75% of the information from the input and process include files.  If
there is, where?

 

Steven Kibler
Flight Trak, Inc.
303.438.8640

888.354.8725

303 466 6091 Direct

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.

 


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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33157] [antlr-interest] FW: Two issues.

2011-07-13 Thread Steven Kibler
Update.  I need the C interface.

 

From: Steven Kibler [mailto:skkib...@earthlink.net] 
Sent: Wednesday, July 13, 2011 13:14
To: 'antlr-interest@antlr.org'
Subject: Two issues.

 

Is there an example of how to request tokens and their information (type,
value, text, etc) from the scanner?   If there is, where?

 

Is there an example of how to feed information into the scanner with other
than a file (a function call)?  By preprocessing the input, I can remove
over 75% of the information from the input and process include files.  If
there is, where?

 

Steven Kibler
Flight Trak, Inc.
303.438.8640

888.354.8725

303 466 6091 Direct

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.

 


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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33159] Re: [antlr-interest] FW: Two issues.

2011-07-13 Thread Jim Idle
Did you read through the example grammars on the download page? Also, the
source code for the default error message method is a good start.

What is it you are trying to do as I am afraid I don't follow your comment
about the pre-processing. In the lexer, the $xxx attributes work too of
course, though I advise you use your own methods for looking at the text
of a token as the built-in stuff is really just a helper if you don't care
about performance very much.

Jim

> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Steven Kibler
> Sent: Wednesday, July 13, 2011 12:16 PM
> To: antlr-interest@antlr.org
> Subject: [antlr-interest] FW: Two issues.
>
> Update.  I need the C interface.
>
>
>
> From: Steven Kibler [mailto:skkib...@earthlink.net]
> Sent: Wednesday, July 13, 2011 13:14
> To: 'antlr-interest@antlr.org'
> Subject: Two issues.
>
>
>
> Is there an example of how to request tokens and their information
> (type,
> value, text, etc) from the scanner?   If there is, where?
>
>
>
> Is there an example of how to feed information into the scanner with
> other than a file (a function call)?  By preprocessing the input, I can
> remove over 75% of the information from the input and process include
> files.  If there is, where?
>
>
>
> Steven Kibler
> Flight Trak, Inc.
> 303.438.8640
>
> 888.354.8725
>
> 303 466 6091 Direct
>
> The information transmitted is intended only for the person or entity
> to which it is addressed and may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of, or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipient is prohibited. If you
> received this in error, please contact the sender and delete the
> material from any computer.
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address

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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33160] [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Udo Weik
Hello,

I just want to access the attributes of INTEGER
and DIGIT - but how?

INTEGER: DIGIT+ { print( "L: (INTEGER): " ) } ;

fragment
DIGIT: '0'..'9' { print( "L: (DIGIT): " ) } ;


Thanks and greetings
Udo

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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33161] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Bart Kiers
Try:

INTEGER
  :  DIGIT+ { print($text) }
  ;


Regards,

Bart.


On Wed, Jul 13, 2011 at 9:57 PM, Udo Weik  wrote:

> Hello,
>
> I just want to access the attributes of INTEGER
> and DIGIT - but how?
>
> INTEGER: DIGIT+ { print( "L: (INTEGER): " ) } ;
>
> fragment
> DIGIT: '0'..'9' { print( "L: (DIGIT): " ) } ;
>
>
> Thanks and greetings
> Udo
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33162] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Bart Kiers
Hi Udo,

`$text` is just a shorthand notation for `$XYZ.text` where `XYZ` is the rule
you're currently in.

Regards,

Bart.


On Wed, Jul 13, 2011 at 10:18 PM, Udo Weik  wrote:

> Hello Bart and others,
>
> yep, thanks, it works...
>
>
>  Try:
>>
>>INTEGER
>>   :  DIGIT+ { print($text) }
>>   ;
>>
>
> 1. Why do I not need the name, here INTEGER, like $INTEGER.text?
> 2. With 12345 the result is
>   L: (DIGIT): 1
>   L: (DIGIT): 12
>   L: (DIGIT): 123
>   L: (DIGIT): 1234
>   L: (DIGIT): 12345
>   L: (INTEGER): 12345
>
>   I expected
>   L: (DIGIT): 1
>   L: (DIGIT): 2
>   L: (DIGIT): 3
>   L: (DIGIT): 4
>   L: (DIGIT): 5
>   L: (INTEGER): 12345
>
>
> Many thanks and greetings
> Udo
>
>
>
>  On Wed, Jul 13, 2011 at 9:57 PM, Udo Weik > weikeng...@aol.com>> wrote:
>>
>>Hello,
>>
>>I just want to access the attributes of INTEGER
>>and DIGIT - but how?
>>
>>INTEGER: DIGIT+ { print( "L: (INTEGER): " ) } ;
>>
>>fragment
>>DIGIT: '0'..'9' { print( "L: (DIGIT): " ) } ;
>>
>>
>>Thanks and greetings
>>Udo
>>
>
>

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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33163] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Bart Kiers
Oh, and since `DIGIT` is called from `INTEGER`, the `$text` from `DIGIT`
references `$INTEGER.text`.

Regards,

Bart.


On Wed, Jul 13, 2011 at 10:18 PM, Udo Weik  wrote:

> Hello Bart and others,
>
> yep, thanks, it works...
>
>
>  Try:
>>
>>INTEGER
>>   :  DIGIT+ { print($text) }
>>   ;
>>
>
> 1. Why do I not need the name, here INTEGER, like $INTEGER.text?
> 2. With 12345 the result is
>   L: (DIGIT): 1
>   L: (DIGIT): 12
>   L: (DIGIT): 123
>   L: (DIGIT): 1234
>   L: (DIGIT): 12345
>   L: (INTEGER): 12345
>
>   I expected
>   L: (DIGIT): 1
>   L: (DIGIT): 2
>   L: (DIGIT): 3
>   L: (DIGIT): 4
>   L: (DIGIT): 5
>   L: (INTEGER): 12345
>
>
> Many thanks and greetings
> Udo
>
>
>
>  On Wed, Jul 13, 2011 at 9:57 PM, Udo Weik > weikeng...@aol.com>> wrote:
>>
>>Hello,
>>
>>I just want to access the attributes of INTEGER
>>and DIGIT - but how?
>>
>>INTEGER: DIGIT+ { print( "L: (INTEGER): " ) } ;
>>
>>fragment
>>DIGIT: '0'..'9' { print( "L: (DIGIT): " ) } ;
>>
>>
>>Thanks and greetings
>>Udo
>>
>
>

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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33164] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Udo Weik
Hello again Bart,

> `$text` is just a shorthand notation for `$XYZ.text` where `XYZ` is the rule 
> you're currently in.

$INTEGER.text doesn't work ("rule INTEGER has no defined parameters"), but your 
$text does.
That's what I don't understand ;(.


Many thanks and greetings
Udo


> On Wed, Jul 13, 2011 at 10:18 PM, Udo Weik  > wrote:
>
> Hello Bart and others,
>
> yep, thanks, it works...
>
>
> Try:
>
> INTEGER
>:  DIGIT+ { print($text) }
>;
>
>
> 1. Why do I not need the name, here INTEGER, like $INTEGER.text?
> 2. With 12345 the result is
>L: (DIGIT): 1
>L: (DIGIT): 12
>L: (DIGIT): 123
>L: (DIGIT): 1234
>L: (DIGIT): 12345
>L: (INTEGER): 12345
>
>I expected
>L: (DIGIT): 1
>L: (DIGIT): 2
>L: (DIGIT): 3
>L: (DIGIT): 4
>L: (DIGIT): 5
>L: (INTEGER): 12345
>
>
> Many thanks and greetings
> Udo
>
>
>
> On Wed, Jul 13, 2011 at 9:57 PM, Udo Weik    >> wrote:
>
> Hello,
>
> I just want to access the attributes of INTEGER
> and DIGIT - but how?
>
> INTEGER: DIGIT+ { print( "L: (INTEGER): " ) } ;
>
> fragment
> DIGIT: '0'..'9' { print( "L: (DIGIT): " ) } ;
>
>
> Thanks and greetings
> Udo


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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33165] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Bart Kiers
Hi Udo,

Ah yes, apologies: you can only reference parser rules like that:

parserRule : LexerRule { print($parserRule.text) } ;


and *not*:

LexerRule : OtherLexerRule { print($LexerRule.text) } ;


Regards,

Bart.


On Wed, Jul 13, 2011 at 10:27 PM, Udo Weik  wrote:

> Hello again Bart,
>
>
>  `$text` is just a shorthand notation for `$XYZ.text` where `XYZ` is the
>> rule you're currently in.
>>
>
> $INTEGER.text doesn't work ("rule INTEGER has no defined parameters"), but
> your $text does.
> That's what I don't understand ;(.
>
>
>
> Many thanks and greetings
> Udo
>
>
>  On Wed, Jul 13, 2011 at 10:18 PM, Udo Weik > weikeng...@aol.com>> wrote:
>>
>>Hello Bart and others,
>>
>>yep, thanks, it works...
>>
>>
>>Try:
>>
>>INTEGER
>>   :  DIGIT+ { print($text) }
>>   ;
>>
>>
>>1. Why do I not need the name, here INTEGER, like $INTEGER.text?
>>2. With 12345 the result is
>>   L: (DIGIT): 1
>>   L: (DIGIT): 12
>>   L: (DIGIT): 123
>>   L: (DIGIT): 1234
>>   L: (DIGIT): 12345
>>   L: (INTEGER): 12345
>>
>>   I expected
>>   L: (DIGIT): 1
>>   L: (DIGIT): 2
>>   L: (DIGIT): 3
>>   L: (DIGIT): 4
>>   L: (DIGIT): 5
>>   L: (INTEGER): 12345
>>
>>
>>Many thanks and greetings
>>Udo
>>
>>
>>
>>On Wed, Jul 13, 2011 at 9:57 PM, Udo Weik > weikeng...@aol.com> >>
>> wrote:
>>
>>Hello,
>>
>>I just want to access the attributes of INTEGER
>>and DIGIT - but how?
>>
>>INTEGER: DIGIT+ { print( "L: (INTEGER): " ) } ;
>>
>>fragment
>>DIGIT: '0'..'9' { print( "L: (DIGIT): " ) } ;
>>
>>
>>Thanks and greetings
>>Udo
>>
>
>

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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33166] [antlr-interest] Is there an updated version of the Whitespace article for antlr v3?

2011-07-13 Thread Jahagirdar, Vijayvithal
I am trying to extend an existing language which only has basic data types 
(int, float etc.) to support complex data types (similar to struct in C).
I was planning to execute the implementation in the following manner.

1.   Write the grammer   --- Done

2.   Write a null translator whose output will be the same as the input --- 
Using the article at " http://www.antlr.org/article/whitespace/index.html  
Preserving whitespace during translation" for reference This was written for 
antler 2.x and does not work with antlr 3.x. Also the files referenced in the 
article are no longer distributed with antlr3. Can anyone help me by pointing 
an equivalent reference that works with antlr3

3.   Perform a first pass over the code to identify all struct definitions 
and populate a list with the same.

4.   Perform a second pass to replace all struct variable declaration's and 
assignments with the normal data types.
Is my approach correct? Is there a better way?

e.g. consider
struct { int a, //declare a
float b //declare b
} xyz;
xyz foo,bar; //two vars
foo.a=bar.a; //assignment
foo=bar;//another variation
f(bar);

I am planning to translate this to

//two vars
int foo_a; //declare a
float foo_b; //declare b
//two vars
int bar_a; //declare a
int bar_b; //declare b
foo_a=bar_a; //assignment

foo_a=bar_a;// another variation a
foo_b=bar_b; // another variation b
f(bar_a,bar_b)
Regards
Vijay


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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.