[il-antlr-interest: 34865] [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Jiwon Seo
I'm trying to add range operator in my language, and I'm having a
problem with it.

The range operator is defined as following:

range: INT '..' INT ;

where INT is '0'..'9'+

I do have FLOAT, but it is defined such that it does not have conflict
with the range operator:

FLOAT: ('0'..'9')+'.'('0'..'9')+ EXPONENT?
| ('0'..'9')+ EXPONENT
  ;

The thing is, if I use the range operator with white spaces before 
after the dots(such as 10 .. 100), it parses fine
But without the white spaces(such as 10..100), it says
'MismatchedTokenException' .

Can anyone see why it's acting like that? I do not use dot ('.') in
any other places.

I'm using antlrworks 1.4.3 for writing grammar and testing it
(interpreter  debugger)

Thanks.

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: 34869] [antlr-interest] [C# target]about efficiency of the code

2011-11-13 Thread 李志鹏
Hello all

I write a very small script language in C#. I have to use box and unbox
again and again in C# code to walk through the AST tree, and a lot of
method use reflection, so i worry about the code efficiency.

anyone have experience walk through tree in C#? how to do more effectively?
can give me some hints?

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: 34870] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Jiwon Seo
I attached a simplified grammar file with the problem.
If you run the interpreter in antlrworks 1.4.3 the following will give an error

int n:0..10

But the following won't give an error:

int n:0 .. 10// white space before and after ..


Note that my definition of FLOAT does not conflict with the range operator:

FLOAT
:   ('0'..'9')+ '.' ('0'..'9')+ EXPONENT?
|   ('0'..'9')+ EXPONENT
;


Thanks.

On Sun, Nov 13, 2011 at 3:09 AM, Christian chw...@gmx.de wrote:
 Hello Jiwon,

 first, try to write a simple minimal grammar that represents your
 usecase because I do not see anything that explains the behavior you
 described. Maybe there are some other rules that influence the parsing.

 Tell us afterwards.

 Regards,
 Christian

 Am 13.11.2011 10:31, schrieb Jiwon Seo:
 I'm trying to add range operator in my language, and I'm having a
 problem with it.

 The range operator is defined as following:

 range: INT '..' INT ;

 where INT is '0'..'9'+

 I do have FLOAT, but it is defined such that it does not have conflict
 with the range operator:

 FLOAT: ('0'..'9')+'.'('0'..'9')+ EXPONENT?
             | ('0'..'9')+ EXPONENT
           ;

 The thing is, if I use the range operator with white spaces before 
 after the dots(such as 10 .. 100), it parses fine
 But without the white spaces(such as 10..100), it says
 'MismatchedTokenException' .

 Can anyone see why it's acting like that? I do not use dot ('.') in
 any other places.

 I'm using antlrworks 1.4.3 for writing grammar and testing it
 (interpreter  debugger)

 Thanks.

 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


simple.g
Description: Binary data
-- 
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: 34871] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Bart Kiers
On Sun, Nov 13, 2011 at 6:59 PM, Jiwon Seo seoji...@gmail.com wrote:

 Thanks for the reply!

 I'm trying to do it without extending lexer since I think my
 definition of FLOAT should not be a problem with the range operator.


But it _is_  a problem if the `..` is preceded by an INT: the ('0'..'9')+
'.' is consumed by FLOAT and can then not match ('0'..'9')+ EXPONENT?,
resulting in the MismatchedTokenException.

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: 34872] [antlr-interest] update on v4

2011-11-13 Thread Terence Parr
Hi, A quick update on v4. I hope to have an early access release sometime late 
December.  Sam Harwell has been hard at work building the new ANTLRWorks and it 
looks great. He has also been invaluable, helping with general architecture and 
API discussions as I move forward with the tool itself.  Shaoting Cai is 
working on gunit  integration for ANTLRWorks. Udo Borkowski is helping with 
graphics for various tools and built the awesome tree layout implementation.

One of the things that I'm using the tree layout for is to help with tree 
parser debugging in v4. In version 3, when you get an error in the tree parser, 
it prints out some obscure message. Now, it's going to pop up a little window 
and show you where in the tree and got confused. E.g.,



sorry for my general silence on the lists…I'm super busy until the end of the 
semester in early December.

Ter

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: 34873] Re: [antlr-interest] update on v4

2011-11-13 Thread Terence Parr
heh! it stripped my window shot. damn! trying with png:

 
On Nov 13, 2011, at 1:26 PM, Terence Parr wrote:

 Hi, A quick update on v4. I hope to have an early access release sometime 
 late December.  Sam Harwell has been hard at work building the new ANTLRWorks 
 and it looks great. He has also been invaluable, helping with general 
 architecture and API discussions as I move forward with the tool itself.  
 Shaoting Cai is working on gunit  integration for ANTLRWorks. Udo Borkowski 
 is helping with graphics for various tools and built the awesome tree layout 
 implementation.
 
 One of the things that I'm using the tree layout for is to help with tree 
 parser debugging in v4. In version 3, when you get an error in the tree 
 parser, it prints out some obscure message. Now, it's going to pop up a 
 little window and show you where in the tree and got confused. E.g.,
 
 
 
 sorry for my general silence on the lists…I'm super busy until the end of the 
 semester in early December.
 
 Ter
 
 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: 34874] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Jiwon Seo
Hmm I see.

Then do I have to extend the lexer like following?

http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+point,+dot,+range,+time+specs

Cause it seems like very complicated for what I want to achieve...
In my language FLOAT does not have a conflict with the range because I
do not allow a float number such as .123
(dot has to be preceded by number like 0.123)

Is there easier way which uses the fact that I'm now allowing .123
style floating point number?

Thanks.

On Sun, Nov 13, 2011 at 10:14 AM, Bart Kiers bki...@gmail.com wrote:
 On Sun, Nov 13, 2011 at 6:59 PM, Jiwon Seo seoji...@gmail.com wrote:

 Thanks for the reply!

 I'm trying to do it without extending lexer since I think my
 definition of FLOAT should not be a problem with the range operator.


 But it _is_  a problem if the `..` is preceded by an INT: the ('0'..'9')+
 '.' is consumed by FLOAT and can then not match ('0'..'9')+ EXPONENT?,
 resulting in the MismatchedTokenException.

 Regards,

 Bart.

 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: 34875] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Fabien Hermenier
Hi

This situation occurred to me recently. Bart, correct me if I am wrong.
It seems like, similar to me, you do not see parsing and lexing as two 
different steps.
Your parser does not allow floats in a range. But prior to the parsing, 
your lexer has to detect if the
the current token it is trying to recognize is a float or a part of an 
integer followed by the range token.
This is why you have to help the lexer recognizing the good tokens using 
a solution
similar to the one explained in the wiki.


Fabien.

Le 13/11/11 16:30, Jiwon Seo a écrit :
 Hmm I see.

 Then do I have to extend the lexer like following?

 http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+point,+dot,+range,+time+specs

 Cause it seems like very complicated for what I want to achieve...
 In my language FLOAT does not have a conflict with the range because I
 do not allow a float number such as .123
 (dot has to be preceded by number like 0.123)

 Is there easier way which uses the fact that I'm now allowing .123
 style floating point number?

 Thanks.

 On Sun, Nov 13, 2011 at 10:14 AM, Bart Kiersbki...@gmail.com  wrote:
 On Sun, Nov 13, 2011 at 6:59 PM, Jiwon Seoseoji...@gmail.com  wrote:

 Thanks for the reply!

 I'm trying to do it without extending lexer since I think my
 definition of FLOAT should not be a problem with the range operator.

 But it _is_  a problem if the `..` is preceded by an INT: the ('0'..'9')+
 '.' is consumed by FLOAT and can then not match ('0'..'9')+ EXPONENT?,
 resulting in the MismatchedTokenException.

 Regards,

 Bart.

 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: 34877] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Jim Idle
Please read the wiki articles - your rules conflict and there are simple
ways around this :)

Jim

 -Original Message-
 From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
 boun...@antlr.org] On Behalf Of Jiwon Seo
 Sent: Sunday, November 13, 2011 9:58 AM
 To: Christian
 Cc: antlr-interest@antlr.org
 Subject: Re: [antlr-interest] Using range operator (INT .. INT)

 I attached a simplified grammar file with the problem.
 If you run the interpreter in antlrworks 1.4.3 the following will give
 an error

 int n:0..10

 But the following won't give an error:

 int n:0 .. 10// white space before and after ..


 Note that my definition of FLOAT does not conflict with the range
 operator:

 FLOAT
 :   ('0'..'9')+ '.' ('0'..'9')+ EXPONENT?
 |   ('0'..'9')+ EXPONENT
 ;


 Thanks.

 On Sun, Nov 13, 2011 at 3:09 AM, Christian chw...@gmx.de wrote:
  Hello Jiwon,
 
  first, try to write a simple minimal grammar that represents your
  usecase because I do not see anything that explains the behavior you
  described. Maybe there are some other rules that influence the
 parsing.
 
  Tell us afterwards.
 
  Regards,
  Christian
 
  Am 13.11.2011 10:31, schrieb Jiwon Seo:
  I'm trying to add range operator in my language, and I'm having a
  problem with it.
 
  The range operator is defined as following:
 
  range: INT '..' INT ;
 
  where INT is '0'..'9'+
 
  I do have FLOAT, but it is defined such that it does not have
  conflict with the range operator:
 
  FLOAT: ('0'..'9')+'.'('0'..'9')+ EXPONENT?
              | ('0'..'9')+ EXPONENT
            ;
 
  The thing is, if I use the range operator with white spaces before 
  after the dots(such as 10 .. 100), it parses fine But without the
  white spaces(such as 10..100), it says 'MismatchedTokenException' .
 
  Can anyone see why it's acting like that? I do not use dot ('.') in
  any other places.
 
  I'm using antlrworks 1.4.3 for writing grammar and testing it
  (interpreter  debugger)
 
  Thanks.
 
  List: http://www.antlr.org/mailman/listinfo/antlr-interest
  Unsubscribe:
  http://www.antlr.org/mailman/options/antlr-interest/your-email-
 addres
  s
 
 
 
  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: 34878] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Jim Idle
I am never sure why this causes so many people so much confusion.
Especially when I published a cut and paste answer to it. Care to say why
you thought it easier to abandon the idea? I am genuinely interested in
the answer.

Jim

 -Original Message-
 From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
 boun...@antlr.org] On Behalf Of Michael Bedward
 Sent: Sunday, November 13, 2011 4:36 PM
 To: Jiwon Seo; antlr-interest@antlr.org interest
 Subject: Re: [antlr-interest] Using range operator (INT .. INT)

 When dealing with the same issue a while ago I decided it was so much
 easier to cheat and use : rather than .. to indicate a range :)

 Michael

 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: 34879] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Michael Bedward
Ah, I wouldn't trouble yourself Jim. I don't remember clearly but it
was most likely a combination of laziness and ignorance on my part.

As post-hoc rationalization, I note that the colon is used as the
sequence operator in the R stats system, in which I do a lot of
scripting, so the syntax seemed natural to me. Whether it does to
anyone using my language (jiffle image scripting) I've no idea.

Michael

On 14 November 2011 12:19, Jim Idle j...@temporal-wave.com wrote:
 I am never sure why this causes so many people so much confusion.
 Especially when I published a cut and paste answer to it. Care to say why
 you thought it easier to abandon the idea? I am genuinely interested in
 the answer.

 Jim

 -Original Message-
 From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
 boun...@antlr.org] On Behalf Of Michael Bedward
 Sent: Sunday, November 13, 2011 4:36 PM
 To: Jiwon Seo; antlr-interest@antlr.org interest
 Subject: Re: [antlr-interest] Using range operator (INT .. INT)

 When dealing with the same issue a while ago I decided it was so much
 easier to cheat and use : rather than .. to indicate a range :)

 Michael

 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: 34880] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Jiwon Seo
I did the following change:

FLOAT
: ('0'..'9')+
(
{input.LA(2) != '.'}? = '.' ('0'..'9')+ EXPONENT? {$type = FLOAT;}
|  {$type = INT;}
)
|  ('0'..'9')+ EXPONENT
;

I tested it inside antlrworks, and very strangely, it works fine with
the debugger(generates the right parse tree),
but raises Mismatched token exception with the interpreter.

Is the above right way to do this?


On Sun, Nov 13, 2011 at 5:10 PM, Jim Idle j...@temporal-wave.com wrote:
 Please read the wiki articles - your rules conflict and there are simple
 ways around this :)

 Jim

 -Original Message-
 From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
 boun...@antlr.org] On Behalf Of Jiwon Seo
 Sent: Sunday, November 13, 2011 9:58 AM
 To: Christian
 Cc: antlr-interest@antlr.org
 Subject: Re: [antlr-interest] Using range operator (INT .. INT)

 I attached a simplified grammar file with the problem.
 If you run the interpreter in antlrworks 1.4.3 the following will give
 an error

 int n:0..10

 But the following won't give an error:

 int n:0 .. 10    // white space before and after ..


 Note that my definition of FLOAT does not conflict with the range
 operator:

 FLOAT
     :   ('0'..'9')+ '.' ('0'..'9')+ EXPONENT?
     |   ('0'..'9')+ EXPONENT
     ;


 Thanks.

 On Sun, Nov 13, 2011 at 3:09 AM, Christian chw...@gmx.de wrote:
  Hello Jiwon,
 
  first, try to write a simple minimal grammar that represents your
  usecase because I do not see anything that explains the behavior you
  described. Maybe there are some other rules that influence the
 parsing.
 
  Tell us afterwards.
 
  Regards,
  Christian
 
  Am 13.11.2011 10:31, schrieb Jiwon Seo:
  I'm trying to add range operator in my language, and I'm having a
  problem with it.
 
  The range operator is defined as following:
 
  range: INT '..' INT ;
 
  where INT is '0'..'9'+
 
  I do have FLOAT, but it is defined such that it does not have
  conflict with the range operator:
 
  FLOAT: ('0'..'9')+'.'('0'..'9')+ EXPONENT?
              | ('0'..'9')+ EXPONENT
            ;
 
  The thing is, if I use the range operator with white spaces before 
  after the dots(such as 10 .. 100), it parses fine But without the
  white spaces(such as 10..100), it says 'MismatchedTokenException' .
 
  Can anyone see why it's acting like that? I do not use dot ('.') in
  any other places.
 
  I'm using antlrworks 1.4.3 for writing grammar and testing it
  (interpreter  debugger)
 
  Thanks.
 
  List: http://www.antlr.org/mailman/listinfo/antlr-interest
  Unsubscribe:
  http://www.antlr.org/mailman/options/antlr-interest/your-email-
 addres
  s
 
 
 
  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.