[il-antlr-interest: 32964] Re: [antlr-interest] No errors on missing tokens?

2011-06-28 Thread Bill Andersen
Partial answer to my own question, in case anyone is interested.

I added all the missing token definitions to my lexer.  When I then compiled 
the lexer and parser and looked at the .tokens files, all the tokens and their 
type #s lined up.  So it seems that:

1) Given a complete lexer, the compilation of the parser grammar is using the 
lexer's .tokens properly

2) Compiling the parser yielded no errors for a complete lexer .tokens file

3) Compiling the parser signalled no errors for an incomplete lexer .tokens file


On Jun 27, 2011, at 22:21 , Bill Andersen wrote:

 Hi Folks
 
 I have a grammar split into a lexer grammar and parser grammar
 
 I have not yet defined all the token types in the lexer, so the parser 
 grammar is making reference to tokens that are not in the lexer .tokens file. 
  The lexer .tokens file has a max token # of 108.  This should produce errors 
 but is not.  BTW, compiling the parser grammar yields a .tokens file with a 
 max token # of 158.  
 
 Can anyone tell me what's going on here?  Thanks
 
   .bill
 
 
 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe: 
 http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Bill Andersen 
Highfleet, Inc. (www.highfleet.com)
3600 O'Donnell Street, Suite 600
Baltimore, MD 21224
Office: +1.410.675.1201
Cell: +1.443.858.6444
Fax: +1.410.675.1204






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: 32965] Re: [antlr-interest] any more issues with 3.4 beta3/rc3?

2011-06-28 Thread Terence Parr

On Jun 27, 2011, at 8:05 PM, Mu Qiao wrote:

 Hi,
 
 I gave a quick test and there are two problems:
 1. I have to set my locale to English, otherwise an exception will be thrown:
 Exception in thread main java.lang.NoClassDefFoundError: org/antlr/Tool

howdy!  How is a java.lang.ClassNotFoundException a locale issue? launching is

$ java org.antlr.Tool

 2. After setting my locale to English, my grammar cannot get compiled:
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)

I'll check it out.
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: 32966] Re: [antlr-interest] any more issues with 3.4 beta3/rc3?

2011-06-28 Thread Terence Parr
BTW, with -Xwatchconversion i see a decision antlr can't deal with:

building lookahead DFA (d=14) for ()* loopback of 111:17: ( ( BLANK !)? 
command_separator ( ( BLANK !)? EOL !)* ( BLANK !)? list_level_1 )*
convert DFA state 0 (407 nfa states)
convert DFA state 1 (279 nfa states)
convert DFA state 2 (751 nfa states)
convert DFA state 3 (438 nfa states)
convert DFA state 4 (749 nfa states)
convert DFA state 20 (693 nfa states)
convert DFA state 21 (614 nfa states)
convert DFA state 22 (603 nfa states)
...

On Jun 27, 2011, at 8:08 PM, Mu Qiao wrote:

 The grammar is attached.
 
 On Tue, Jun 28, 2011 at 11:05 AM, Mu Qiao qiao...@gmail.com wrote:
 Hi,
 
 I gave a quick test and there are two problems:
 1. I have to set my locale to English, otherwise an exception will be thrown:
 Exception in thread main java.lang.NoClassDefFoundError: org/antlr/Tool
 Caused by: java.lang.ClassNotFoundException: org.antlr.Tool
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
 Exception in thread main java.lang.NoClassDefFoundError: org/antlr/Tool
 Caused by: java.lang.ClassNotFoundException: org.antlr.Tool
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
 
 2. After setting my locale to English, my grammar cannot get compiled:
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)
 
 On Tue, Jun 28, 2011 at 8:05 AM, Terence Parr pa...@cs.usfca.edu wrote:
 please try this out on your stuff. should be backward compatible; we'll 
 release soon.
 
 http://antlr.org/download/antlr-master-3.4-beta3-completejar.jar
 http://antlr.org/download/antlr-master-3.4-beta3-src.jar
 http://antlr.org/download/antlr-runtime-3.4-beta3-sources.jar
 http://antlr.org/download/antlr-runtime-3.4-beta3.jar
 
 Ter
 
 
 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe: 
 http://www.antlr.org/mailman/options/antlr-interest/your-email-address
 
 
 
 
 --
 Best wishes,
 Mu Qiao
 GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5  3ACC 30B3 0DE4 17B1 57E9
 
 
 
 
 -- 
 Best wishes,
 Mu Qiao
 GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5  3ACC 30B3 0DE4 17B1 57E9
 java_libbash.g


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: 32967] Re: [antlr-interest] any more issues with 3.4 beta3/rc3?

2011-06-28 Thread Terence Parr

On Jun 27, 2011, at 8:05 PM, Mu Qiao wrote:
 2. After setting my locale to English, my grammar cannot get compiled:
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(26!=2)
 error(100): java_libbash.g:0:1: syntax error: antlr.print:
 MismatchedTreeNodeException(28!=2)

Fixed.

thanks!

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: 32968] [antlr-interest] Interesting parser grammar issue

2011-06-28 Thread Bill Andersen
(Using 3.3)

Check out this partial grammar for SPARQL 1.1 
(http://www.w3.org/TR/sparql11-query/)

// [2]
query
: prologue 
  ( select_query
  | construct_query
  | describe_query
  | ask_query
  )
  bindings_clause 
;

// [4]
prologue
: prologue_decl*
; 

// [4.1]
prologue_decl
  : prefix_decl
  | base_decl
  ;

// [5]
base_decl
: BASE IRI_REF
;

// [6]
prefix_decl
: PREFIX PNAME_NS IRI_REF
;

The above version works - at least for SELECT queries.  The original production 
[4] that I replaced with [4] and [4.1] looked like

// [4]
prologue
: ( base_decl | prefix_decl )*
;

The grammar with this production will fail to parse SPARQL queries like the 
following, with the error NoViableAltException: line 1:0 no viable alternative 
at input 'PREFIX'

PREFIX  data:  http://example.org/foaf/
PREFIX  foaf:  http://xmlns.com/foaf/0.1/
PREFIX  rdfs:  http://www.w3.org/2000/01/rdf-schema#

SELECT ?mbox ?nick ?ppd
FROM NAMED http://example.org/foaf/aliceFoaf
FROM NAMED http://example.org/foaf/bobFoaf
WHERE
{
  GRAPH data:aliceFoaf
  {
?alice foaf:mbox alice ;
   foaf:knows ?whom .
?whom  foaf:mbox ?mbox ;
   rdfs:seeAlso ?ppd .
?ppd  a foaf:PersonalProfileDocument .
  } .
  GRAPH ?ppd
  {
  ?w foaf:mbox ?mbox ;
 foaf:nick ?nick
  }
}

So, why should the new [4] + [4.1] combination work where the original [4] 
would not?



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: 32969] [antlr-interest] antlr 3.4 beta 4 (release candidate)

2011-06-28 Thread Terence Parr
http://antlr.org/download

a few more things fixed.

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: 32970] Re: [antlr-interest] No errors on missing tokens?

2011-06-28 Thread Kirby Bohling
Naturally I forgot to add ANTLR Interest to by Reply-To, so the
information is captured in case it is useful to others.   I didn't
think you'd mind my inclusion of your reply also.

On Tue, Jun 28, 2011 at 12:52 PM, Bill Andersen ander...@highfleet.com wrote:
 Thanks, Kirby

 Yup.  I triple (no.. quadruple) checked that.  I cleaned the project, 
 manually deleted the .tokens files, etc.  All the standard stuff.  Sorry...  
 My questions to the list tend to be a little ADD-like and I leave out 
 important details like that.

 This is a genuine bug unless I'm missing something really obvious.

 BTW, great reply.  Doesn't help me but it will help ANTLR newbies.

        .bill

 On Jun 28, 2011, at 13:45 , Kirby Bohling wrote:

 On Tue, Jun 28, 2011 at 12:34 PM, Bill Andersen ander...@highfleet.com 
 wrote:
 Partial answer to my own question, in case anyone is interested.

 I added all the missing token definitions to my lexer.  When I then 
 compiled the lexer and parser and looked at the .tokens files, all the 
 tokens and their type #s lined up.  So it seems that:

 1) Given a complete lexer, the compilation of the parser grammar is using 
 the lexer's .tokens properly

 2) Compiling the parser yielded no errors for a complete lexer .tokens file

 3) Compiling the parser signalled no errors for an incomplete lexer .tokens 
 file


 On Jun 27, 2011, at 22:21 , Bill Andersen wrote:

 Hi Folks

 I have a grammar split into a lexer grammar and parser grammar

 I have not yet defined all the token types in the lexer, so the parser 
 grammar is making reference to tokens that are not in the lexer .tokens 
 file.  The lexer .tokens file has a max token # of 108.  This should 
 produce errors but is not.  BTW, compiling the parser grammar yields a 
 .tokens file with a max token # of 158.

 Can anyone tell me what's going on here?  Thanks

       .bill


 Looking at your original question, did you have the correct
 declaration tokenVocab in your options section in the Parser/Tree
 grammars?

 options {
 ...
    tokenVocab=MyNameHereLexer;
 ...
 }

 I use Maven, so it always generates both the Lexer and Parser at the
 same time (and if you have TreeGrammars, you'll definitely need this
 there).  I'm not sure if you need to process both in a single run or
 not.  I always declare all my virtual tokens in my Lexer so I have one
 file that has them all, but I know that it isn't necessary (I put them
 temporarily in the Parser while until I get everything working then
 migrate them to the lexer as I add rules that need virtual tokens).
 However, if you don't declare the tokenVocab and you have split
 Lexer/Parser grammars it definitely causes problems with tokens not
 being in sync, and the types of things you are describing.

 Not sure if this is your problem, but it is how I have problems like
 what you are describing.  So even if it doesn't help you, hopefully it
 helps others quickly spot one of my beginner mistakes with ANTLR.

 Kirby

 Bill Andersen
 Highfleet, Inc. (www.highfleet.com)
 3600 O'Donnell Street, Suite 600
 Baltimore, MD 21224
 Office: +1.410.675.1201
 Cell: +1.443.858.6444
 Fax: +1.410.675.1204







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: 32972] Re: [antlr-interest] C runtime 3.4 beta 4

2011-06-28 Thread Mu Qiao
Now this version takes quite long time to generate the source code. I
know there are many issues in my grammar (java_libbash.g attached in
previous email). But 3.1 and 3.3 can generate the source code in less
than 30 seconds. Now it takes 10 minutes and I don't see it's ending.
Some output with -X -Xwatchconversion

convert DFA state 7103 (32 nfa states)
convert DFA state 7104 (799 nfa states)
convert DFA state 7600 (1017 nfa states)
convert DFA state 7601 (1017 nfa states)
convert DFA state 7602 (1009 nfa states)
convert DFA state 7603 (1009 nfa states)
convert DFA state 7604 (1005 nfa states)
convert DFA state 7605 (1505 nfa states)
convert DFA state 7607 (5682 nfa states)
convert DFA state 7608 (535 nfa states)
convert DFA state 7612 (1019 nfa states)
convert DFA state 7613 (33 nfa states)
convert DFA state 7614 (1015 nfa states)
convert DFA state 7615 (1015 nfa states)
convert DFA state 7616 (1015 nfa states)
convert DFA state 7617 (1015 nfa states)
..

On Wed, Jun 29, 2011 at 5:07 AM, Jim Idle j...@temporal-wave.com wrote:
 http://antlr.org/download/C



 Jim

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




-- 
Best wishes,
Mu Qiao
GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5  3ACC 30B3 0DE4 17B1 57E9

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: 32976] [antlr-interest] Someting about range (to change)

2011-06-28 Thread Fabien Hermenier
Hi

I am sorry, but this is another problem related to sequence of integer. 
I don't understand my error(s), despite severals
pass on the wiki page related to this use case.

I want to parse a string with a sequence parameter into it, such as 
toto-[2 ..3]-toto.
Here is a short version of the grammar that works perfectly:
---
grammar tryout;

options {
 k=3;
}
fragment Digit :'0'..'9';
DEC_NUMBER: '1'..'9' Digit*;

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

WS:('\n'|'\r'|'\t'|' ') {$channel=HIDDEN;};
LEFTY: (Letter|Digit) (Letter|Digit|'-')* '[';
RIGHTY: ']' (('-' (Letter|Digit))|Letter|Digit)* ;


number :DEC_NUMBER; //HEX_NUMBER, OCT_NUMBER, ... are following but 
removed for this example.

range: LEFTY number '..' number RIGHTY;
---

This grammar accepts toto-[1..3]-toto or toto-[1 .. 3]-toto.
Now, I want to be able to accept the LEFTY token or the RIGHTY token 
even if they contains a '.' inside (not at the beginning). So I've 
modified LEFTY as following:
LEFTY: (Letter|Digit) ('.'|Letter|Digit|'-')* '[';

Now, ANTLR does no longer accept toto-[1..3]-toto. It requires at 
least one space between the first number and the range.
I have read the wiki page related to range, integer, and so one. But in 
my case, I don't see where my grammar is ambiguous as no token
can start with a '.' . So it seems there is a concept I don't get. Can 
anyone try to help me ?

Thanks in advance,
Fabien.

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: 32978] Re: [antlr-interest] Someting about range (to change)

2011-06-28 Thread Bart Kiers
Hi Fabien,

Can you post the grammar that produces the error?

Bart.


On Wed, Jun 29, 2011 at 5:57 AM, Fabien Hermenier hermenierfab...@gmail.com
 wrote:

 Hi

 I am sorry, but this is another problem related to sequence of integer.
 I don't understand my error(s), despite severals
 pass on the wiki page related to this use case.

 I want to parse a string with a sequence parameter into it, such as
 toto-[2 ..3]-toto.
 Here is a short version of the grammar that works perfectly:
 ---
 grammar tryout;

 options {
 k=3;
 }
 fragment Digit :'0'..'9';
 DEC_NUMBER: '1'..'9' Digit*;

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

 WS:('\n'|'\r'|'\t'|' ') {$channel=HIDDEN;};
 LEFTY: (Letter|Digit) (Letter|Digit|'-')* '[';
 RIGHTY: ']' (('-' (Letter|Digit))|Letter|Digit)* ;


 number :DEC_NUMBER; //HEX_NUMBER, OCT_NUMBER, ... are following but
 removed for this example.

 range: LEFTY number '..' number RIGHTY;
 ---

 This grammar accepts toto-[1..3]-toto or toto-[1 .. 3]-toto.
 Now, I want to be able to accept the LEFTY token or the RIGHTY token
 even if they contains a '.' inside (not at the beginning). So I've
 modified LEFTY as following:
 LEFTY: (Letter|Digit) ('.'|Letter|Digit|'-')* '[';

 Now, ANTLR does no longer accept toto-[1..3]-toto. It requires at
 least one space between the first number and the range.
 I have read the wiki page related to range, integer, and so one. But in
 my case, I don't see where my grammar is ambiguous as no token
 can start with a '.' . So it seems there is a concept I don't get. Can
 anyone try to help me ?

 Thanks in advance,
 Fabien.

 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: 32979] Re: [antlr-interest] Someting about range (to change)

2011-06-28 Thread Fabien Hermenier
Hi Bart

Here is. It's just a change in LEFTY:
---
fragment Digit :'0'..'9';
DEC_NUMBER: '1'..'9' Digit*;

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

WS:('\n'|'\r'|'\t'|' ') {$channel=HIDDEN;};
LEFTY: (Letter|Digit) ('.'|Letter|Digit|'-')* '[';
RIGHTY: ']' (('-' (Letter|Digit))|Letter|Digit)* ;

number :DEC_NUMBER;

range: LEFTY number '..' number RIGHTY;
---

Le 28/06/11 23:51, Bart Kiers a écrit :
 Hi Fabien,

 Can you post the grammar that produces the error?

 Bart.


 On Wed, Jun 29, 2011 at 5:57 AM, Fabien Hermenier 
 hermenierfab...@gmail.com mailto:hermenierfab...@gmail.com wrote:

 Hi

 I am sorry, but this is another problem related to sequence of
 integer.
 I don't understand my error(s), despite severals
 pass on the wiki page related to this use case.

 I want to parse a string with a sequence parameter into it, such as
 toto-[2 ..3]-toto.
 Here is a short version of the grammar that works perfectly:
 ---
 grammar tryout;

 options {
 k=3;
 }
 fragment Digit :'0'..'9';
 DEC_NUMBER: '1'..'9' Digit*;

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

 WS:('\n'|'\r'|'\t'|' ') {$channel=HIDDEN;};
 LEFTY: (Letter|Digit) (Letter|Digit|'-')* '[';
 RIGHTY: ']' (('-' (Letter|Digit))|Letter|Digit)* ;


 number :DEC_NUMBER; //HEX_NUMBER, OCT_NUMBER, ... are following but
 removed for this example.

 range: LEFTY number '..' number RIGHTY;
 ---

 This grammar accepts toto-[1..3]-toto or toto-[1 .. 3]-toto.
 Now, I want to be able to accept the LEFTY token or the RIGHTY token
 even if they contains a '.' inside (not at the beginning). So I've
 modified LEFTY as following:
 LEFTY: (Letter|Digit) ('.'|Letter|Digit|'-')* '[';

 Now, ANTLR does no longer accept toto-[1..3]-toto. It requires at
 least one space between the first number and the range.
 I have read the wiki page related to range, integer, and so one.
 But in
 my case, I don't see where my grammar is ambiguous as no token
 can start with a '.' . So it seems there is a concept I don't get. Can
 anyone try to help me ?

 Thanks in advance,
 Fabien.

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




-- 
postdoctoral researcher at Flux
School of Computing, University of Utah
http://sites.google.com/site/hermenierfabien/home


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.