[il-antlr-interest: 30355] Re: [antlr-interest] Tree grammar: How to handle rule arguments

2010-10-16 Thread Bart Kiers
On Sat, Oct 16, 2010 at 1:16 AM, Stephanie Balzer 
stephanie.bal...@gmail.com wrote:


 ... What is the meaning of id+= above?


A java.util.List is defined at the start of the rule and
all Identifier-tokens are added to it.

Token id=null;
List list_id=null; *// - !!!*

try {
// Test.g:17:3: (id+= Identifier ( ',' id+= Identifier )* )
// Test.g:17:6: id+= Identifier ( ',' id+= Identifier )*
{
id=(Token)match(input,Identifier,FOLLOW_Identifier_in_ids80);
if (list_id==null) list_id=new ArrayList();  *// - !!!*
list_id.add(id);  *// - !!!*
...

Regards,

Bart.

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: 30358] Re: [antlr-interest] very simple doubt about EXPR grammar

2010-10-16 Thread Leonardo K. Shikida
Hi Jim

but I´ve actually posted the grammar twice in this thread. :-)

the problem here seems to be exactly what John has noticed: I can´t
rely on ANTLR Works because its interpreter does not give me what the
generated java code actually does.

Is there anywhere I can send ANTLR Works team some bug report?

TIA

Leo



grammar Expr;

@header {
}

@members {
}


stat:   comp ';'
   ;

comp
   :   e=expr
   (   '' expr
   |   '' expr
   |   '=' expr
   )*
   ;

expr
   :   e=multExpr
   (   '+' multExpr
   |   '-' multExpr
   |   '*' multExpr
   |   '/' multExpr
   )*
   ;

multExpr
   :   atom
   (   atom
   )*
   ;

atom
   :   INT
   |   ID
   |  '(' comp ')'
   ;

ID  :   ('a'..'z'|'_')+ ;
INT :   '0'..'9'+ ;
WS  :   (' '|'\t')+  ;

[]

Leonardo K. Shikida





On Fri, Oct 15, 2010 at 2:07 PM, Jim Idle j...@temporal-wave.com wrote:
 You need to post your grammar and code, not screen shots. First though,
 delete everything the was generated and start from a clean directory. You
 are just doing something silly somewhere, but we can’t see what it is unless
 you post all your code. Also, as you are using Java, you should look at
 Maven for your builds.

 Jim

 -Original Message-
 From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
 boun...@antlr.org] On Behalf Of Leonardo K. Shikida
 Sent: Thursday, October 14, 2010 5:19 PM
 To: John B. Brodie
 Cc: antlr-interest@antlr.org
 Subject: Re: [antlr-interest] very simple doubt about EXPR grammar

 Hi John

 here are some screenshots of what I am doing with ANTLR Works.

 not ok: http://img833.imageshack.us/img833/7586/noviable.png

 ok: http://img194.imageshack.us/img194/7260/viable.png

 so strange it only happens to the MINUS sign.

 thanks

 Leo





 On Thu, Oct 14, 2010 at 5:17 PM, John B. Brodie j...@acm.org wrote:
  Greetings!
  On Thu, 2010-10-14 at 09:31 -0300, Leonardo K. Shikida wrote:
  Hi Kevin
 
  You´re right. So I´ve changed the grammar to include a stopword
 (semicolon).
 
  Still the same problem.
 
  1-1+1; generates a NoViableAltException
 
  very strange...
 
 
  while
 
  1+1-1; does not
 
  This is very strange because according to the rule
 
  expr
      :   e=multExpr
          (   '+' multExpr
          |   '-' multExpr
          |   '*' multExpr
          |   '/' multExpr
          )*
      ;
 
  it does not matter what symbol comes. In fact, for all other
  combinations of symbols in the same expression, only those starting
  with 1-1 throws the exception.
 
  1*1-1; OK
  1*1/1; OK
  1-1-1; NOT OK
  1*1+1; OK
 
  unable to reproduce. attached please find a complete test grammar
  including a test driver that contains your grammar.
 
  this test grammar parses all four of the above without any problem.
 
  (does your test input happen to (incorrectly) include a blank(s)? your
  lexer accepts white space but your parser does not)
 
 
  and so on...
 
  Can anyone help me? Is it an ANTLR bug or am I missing something here
  in this grammar?
 
  Thanks in advance
 
  Leo.
 
  
 
  grammar Expr;
 
  @header {
  }
 
  @members {
  }
 
 
  stat:   comp ';'
      ;
 
  comp
      :   e=expr
          (   '' expr
          |   '' expr
          |   '=' expr
          )*
      ;
 
  expr
      :   e=multExpr
          (   '+' multExpr
          |   '-' multExpr
          |   '*' multExpr
          |   '/' multExpr
          )*
      ;
 
  multExpr
        :       atom
        (       atom
        )*
      ;
 
  atom
      :   INT
      |   ID
      |  '(' comp ')'
      ;
 
  ID  :   ('a'..'z'|'_')+ ;
  INT :   '0'..'9'+ ;
  WS  :   (' '|'\t')+  ;
 
  []
 
  Leonardo K. Shikida
 
 
 
 
 
  On Wed, Oct 13, 2010 at 3:14 PM, Kevin J. Cummings
  cummi...@kjchome.homeip.net wrote:
   On 10/13/2010 01:29 PM, Leonardo K. Shikida wrote:
   Hi
  
   This is something stupid, I guess. I have a grammar like this
   below and I would like to know why
  
   1+1-1 works
  
   and
  
   1-1+1 does not work (NoViableAltException)
  
   NoViableAltException is thrown in your stat rule when it can't
   predict an INT, ID, (, or NEWLINE in the lookahead.  Does your test
   case end in a NEWLINE?
  
   Thanks
  
   Leo K.
  
   --
   Kevin J. Cummings
   kjch...@rcn.com
   cummi...@kjchome.homeip.net
   cummi...@kjc386.framingham.ma.us
   Registered Linux User #1232 (http://counter.li.org)
  
 
 

 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-interest: 30359] [antlr-interest] ANTLR3-Task: setting debugging port number

2010-10-16 Thread Stephanie
Hello,

I use the ANTLR3-Task to integrate ANTLR with Eclipse. To debug my walker
remotely in ANTLRWorks, I use the task's debug option. Unfortunately, the
default port doesn't work for me and I have to change the port. Currently, I
change the port manually in the generated Walker.java file, i.e., in below
constructor I override DebugEventSocketProxy.DEFAULT_DEBUGGER_PORT with my
port number.

public JavaliWalker(TreeNodeStream input) {

this(input, DebugEventSocketProxy.DEFAULT_DEBUGGER_PORT,
newRecognizerSharedState());

}


Is there a way to configure the port number?

Regards,

Stephanie

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.