Indhu Bharathi | 8 Apr 2009 04:21

Re: [antlr-interest] Why doesn't this work?

Moving this to antlr-dev as I'm starting to feel maybe this is a bug... No reply in antlr-interest for long time kindof confirms that feeling.

I can certainly do some work around for the work I'm doing now. But this is something I've tried a lot of times and always failed. Would like to know if I'm doing some mistake or is this a bug in ANTLR?

Thanks, Indhu

Indhu Bharathi wrote:
Hi, Any clue why this doesn't work? I'm still clueless. - Indhu Indhu Bharathi wrote:
I was working in a big grammar and stumbled on a problem with predicates. I've simplified the problem as much as possible and here it is: When I give the input "1.", I expect the tokens <INT_LIT, DOT>. But what I get is "No viable alternative at character 'EOF'. I'm not able to understand why this happens. Any pointers? grammar Test; r : INT_LIT DOT+ ; INT_FLOAT_PATTERN : (NUMBER DOT NUMBER LETTER ) => NUMBER DOT NUMBER LETTER { $type=PATTERN; } | ( NUMBER DOT NUMBER ) => NUMBER DOT NUMBER { $type=FLOAT_LIT; } | (NUMBER) => NUMBER { $type=INT_LIT; } ; DOT : '.' ; fragment PATTERN : ; fragment FLOAT_LIT : ; fragment INT_LIT : ; fragment NUMBER : ('0'..'9')+ ; fragment LETTER : 'a'..'z' ; Thanks, Indhu 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

<div>
Moving this to antlr-dev as I'm starting to feel maybe this is a bug...
No reply in antlr-interest for long time kindof confirms that feeling.<br><br>
I can certainly do some work around for the work I'm doing now. But
this is something I've tried a lot of times and always failed. Would
like to know if I'm doing some mistake or is this a bug in ANTLR? <br><br>
Thanks, Indhu<br><br>
Indhu Bharathi wrote:
<blockquote cite="mid:49DB8166.4050800@..." type="cite">
  Hi,

Any clue why this doesn't work? I'm still clueless.

- Indhu

Indhu Bharathi wrote:

  <blockquote type="cite">
    I was working in a big grammar and stumbled on a problem with 
predicates. I've simplified the problem as much as possible and here it is:

When I give the input "1.", I expect the tokens &lt;INT_LIT, DOT&gt;. But what 
I get is "No viable alternative at character 'EOF'. I'm not able to 
understand why this happens. Any pointers?

grammar Test;

r    :    INT_LIT DOT+
    ;

INT_FLOAT_PATTERN
    :    (NUMBER DOT NUMBER LETTER ) =&gt; NUMBER DOT NUMBER LETTER
        { $type=PATTERN; }

    |    ( NUMBER DOT NUMBER ) =&gt;  NUMBER DOT NUMBER
        { $type=FLOAT_LIT; }

    |    (NUMBER) =&gt; NUMBER
        { $type=INT_LIT; }

    ;

DOT    :    '.'
    ;

fragment PATTERN
    :    ;

fragment FLOAT_LIT
    :    ;

fragment INT_LIT
    :    ;   

   
fragment
NUMBER    :    ('0'..'9')+
    ;

fragment
LETTER    :    'a'..'z'
    ;

Thanks, Indhu

List: <a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/listinfo/antlr-interest">http://www.antlr.org/mailman/listinfo/antlr-interest</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/options/antlr-interest/your-email-address">http://www.antlr.org/mailman/options/antlr-interest/your-email-address</a>

  

  </blockquote>

List: <a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/listinfo/antlr-interest">http://www.antlr.org/mailman/listinfo/antlr-interest</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/options/antlr-interest/your-email-address">http://www.antlr.org/mailman/options/antlr-interest/your-email-address</a>

  
</blockquote>
<br>
</div>
Johannes Luber | 8 Apr 2009 10:32
Picon
Picon

Re: [antlr-interest] Why doesn't this work?

Indhu Bharathi schrieb:
> Moving this to antlr-dev as I'm starting to feel maybe this is a bug...
> No reply in antlr-interest for long time kindof confirms that feeling.
> 
> I can certainly do some work around for the work I'm doing now. But this
> is something I've tried a lot of times and always failed. Would like to
> know if I'm doing some mistake or is this a bug in ANTLR?
> 
> Thanks, Indhu

I think that your problem is described here:
<http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+point,+dot,+range,+time+specs>

Johannes
> 
> Indhu Bharathi wrote:
>> Hi,
>>
>> Any clue why this doesn't work? I'm still clueless.
>>
>> - Indhu
>>
>> Indhu Bharathi wrote:
>>   
>>> I was working in a big grammar and stumbled on a problem with 
>>> predicates. I've simplified the problem as much as possible and here it is:
>>>
>>> When I give the input "1.", I expect the tokens <INT_LIT, DOT>. But what 
>>> I get is "No viable alternative at character 'EOF'. I'm not able to 
>>> understand why this happens. Any pointers?
>>>
>>> grammar Test;
>>>
>>> r    :    INT_LIT DOT+
>>>     ;
>>>
>>> INT_FLOAT_PATTERN
>>>     :    (NUMBER DOT NUMBER LETTER ) => NUMBER DOT NUMBER LETTER
>>>         { $type=PATTERN; }
>>>        
>>>     |    ( NUMBER DOT NUMBER ) =>  NUMBER DOT NUMBER
>>>         { $type=FLOAT_LIT; }
>>>
>>>     |    (NUMBER) => NUMBER
>>>         { $type=INT_LIT; }
>>>
>>>     ;
>>>
>>> DOT    :    '.'
>>>     ;
>>>
>>> fragment PATTERN
>>>     :    ;
>>>    
>>> fragment FLOAT_LIT
>>>     :    ;
>>>    
>>> fragment INT_LIT
>>>     :    ;   
>>>
>>>    
>>> fragment
>>> NUMBER    :    ('0'..'9')+
>>>     ;
>>>
>>> fragment
>>> LETTER    :    'a'..'z'
>>>     ;
>>>    
>>>
>>> Thanks, Indhu
>>>
>>>
>>> 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
>>
>>   
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> antlr-dev mailing list
> antlr-dev@...
> http://www.antlr.org/mailman/listinfo/antlr-dev

Indhu Bharathi | 8 Apr 2009 11:08

Re: [antlr-interest] Why doesn't this work?

Yes, I've read that page earlier and I understand it (and that is how I've solved the problem for now). Without syntactic predicates I understand ANTLR Lexer will try matching the longer string and might fail in the middle. But when a syntactic predicate (which is a gated semantic predicate) is placed before the production, shouldn't ANTLR first try the predicate and go on and match the production only if the syntactic predicate passes like what Terence says here: http://www.antlr.org/pipermail/antlr-interest/2009-March/033526.html

For example, the following grammar wont work for the input "1.". It wont give me INT_LIT, DOT. Instead it will try matching for FLOAT_LIT and fail. :

grammar Test;

r    :    INT_LIT DOT
    ;

INT_OR_FLOAT
    :    NUMBER DOT NUMBER  {$type=FLOAT_LIT;}
    |    NUMBER {$type=INT_LIT;}
    ;

fragment INT_LIT
    :    ;
   
fragment FLOAT_LIT
    :    ;

DOT    :    '.'
    ;

fragment NUMBER
    :    '0'..'9'+
    ;
   

But if you add syntactic predicate to INT_OR_FLOAT as shown below, it will work:

INT_OR_FLOAT
    :    (NUMBER DOT NUMBER) => NUMBER DOT NUMBER  {$type=FLOAT_LIT;}
    |    (NUMBER) => NUMBER {$type=INT_LIT;}
    ;


I was expecting the same thing on my example. But it for some reason doesn't work for my example. What is the difference between the above example and my example? Shouldn't both work fine since syntactic predicate is present?

Thanks, Indhu

Johannes Luber wrote:
Indhu Bharathi schrieb:
Moving this to antlr-dev as I'm starting to feel maybe this is a bug... No reply in antlr-interest for long time kindof confirms that feeling. I can certainly do some work around for the work I'm doing now. But this is something I've tried a lot of times and always failed. Would like to know if I'm doing some mistake or is this a bug in ANTLR? Thanks, Indhu
I think that your problem is described here: <http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+point,+dot,+range,+time+specs> Johannes
Indhu Bharathi wrote:
Hi, Any clue why this doesn't work? I'm still clueless. - Indhu Indhu Bharathi wrote:
I was working in a big grammar and stumbled on a problem with predicates. I've simplified the problem as much as possible and here it is: When I give the input "1.", I expect the tokens <INT_LIT, DOT>. But what I get is "No viable alternative at character 'EOF'. I'm not able to understand why this happens. Any pointers? grammar Test; r : INT_LIT DOT+ ; INT_FLOAT_PATTERN : (NUMBER DOT NUMBER LETTER ) => NUMBER DOT NUMBER LETTER { $type=PATTERN; } | ( NUMBER DOT NUMBER ) => NUMBER DOT NUMBER { $type=FLOAT_LIT; } | (NUMBER) => NUMBER { $type=INT_LIT; } ; DOT : '.' ; fragment PATTERN : ; fragment FLOAT_LIT : ; fragment INT_LIT : ; fragment NUMBER : ('0'..'9')+ ; fragment LETTER : 'a'..'z' ; Thanks, Indhu 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
------------------------------------------------------------------------ _______________________________________________ antlr-dev mailing list antlr-dev-ErkRXerACLvYtjvyW6yDsg@public.gmane.org http://www.antlr.org/mailman/listinfo/antlr-dev

<div>
Yes, I've read that page earlier and I understand it (and that is how
I've solved the problem for now). Without syntactic predicates I
understand ANTLR Lexer will try matching the longer string and might
fail in the middle. But when a syntactic predicate (which is a gated
semantic predicate) is placed before the production, shouldn't ANTLR
first try the predicate and go on and match the production only if the
syntactic predicate passes like what Terence says here:
<a class="moz-txt-link-freetext" href="http://www.antlr.org/pipermail/antlr-interest/2009-March/033526.html">http://www.antlr.org/pipermail/antlr-interest/2009-March/033526.html</a><br><br>
For example, the following grammar wont work for the input "1.". It
wont give me INT_LIT, DOT. Instead it will try matching for FLOAT_LIT
and fail. :<br><br>
grammar Test;<br><br>
r&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; INT_LIT DOT<br>
&nbsp;&nbsp;&nbsp; ;<br><br>
INT_OR_FLOAT<br>
&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; NUMBER DOT NUMBER&nbsp; {$type=FLOAT_LIT;}<br>
&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; NUMBER {$type=INT_LIT;}<br>
&nbsp;&nbsp;&nbsp; ;<br><br>
fragment INT_LIT<br>
&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; ;<br>
&nbsp;&nbsp;&nbsp; <br>
fragment FLOAT_LIT<br>
&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; ;<br><br>
DOT&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; '.'<br>
&nbsp;&nbsp;&nbsp; ;<br><br>
fragment NUMBER<br>
&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; '0'..'9'+<br>
&nbsp;&nbsp;&nbsp; ;<br>
&nbsp;&nbsp;&nbsp; <br><br>
But if you add syntactic predicate to INT_OR_FLOAT as shown below, it
will work:<br><br>
INT_OR_FLOAT<br>
&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; (NUMBER DOT NUMBER) =&gt; NUMBER DOT NUMBER&nbsp; {$type=FLOAT_LIT;}<br>
&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; (NUMBER) =&gt; NUMBER {$type=INT_LIT;}<br>
&nbsp;&nbsp;&nbsp; ;<br><br><br>
I was expecting the same thing on my example. But it for some reason
doesn't work for my example. What is the difference between the above
example and my example? Shouldn't both work fine since syntactic
predicate is present?<br><br>
Thanks, Indhu<br><br>
Johannes Luber wrote:
<blockquote cite="mid:49DC6120.2010200@..." type="cite">
  Indhu Bharathi schrieb:

  <blockquote type="cite">
    Moving this to antlr-dev as I'm starting to feel maybe this is a bug...
No reply in antlr-interest for long time kindof confirms that feeling.

I can certainly do some work around for the work I'm doing now. But this
is something I've tried a lot of times and always failed. Would like to
know if I'm doing some mistake or is this a bug in ANTLR?

Thanks, Indhu

  </blockquote>

I think that your problem is described here:
<a class="moz-txt-link-rfc2396E" href="http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+point,+dot,+range,+time+specs">&lt;http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+point,+dot,+range,+time+specs&gt;</a>

Johannes

  <blockquote type="cite">
    Indhu Bharathi wrote:

    <blockquote type="cite">
      Hi,

Any clue why this doesn't work? I'm still clueless.

- Indhu

Indhu Bharathi wrote:

      
      <blockquote type="cite">
        I was working in a big grammar and stumbled on a problem with 
predicates. I've simplified the problem as much as possible and here it is:

When I give the input "1.", I expect the tokens &lt;INT_LIT, DOT&gt;. But what 
I get is "No viable alternative at character 'EOF'. I'm not able to 
understand why this happens. Any pointers?

grammar Test;

r    :    INT_LIT DOT+
    ;

INT_FLOAT_PATTERN
    :    (NUMBER DOT NUMBER LETTER ) =&gt; NUMBER DOT NUMBER LETTER
        { $type=PATTERN; }

    |    ( NUMBER DOT NUMBER ) =&gt;  NUMBER DOT NUMBER
        { $type=FLOAT_LIT; }

    |    (NUMBER) =&gt; NUMBER
        { $type=INT_LIT; }

    ;

DOT    :    '.'
    ;

fragment PATTERN
    :    ;

fragment FLOAT_LIT
    :    ;

fragment INT_LIT
    :    ;   

   
fragment
NUMBER    :    ('0'..'9')+
    ;

fragment
LETTER    :    'a'..'z'
    ;

Thanks, Indhu

List: <a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/listinfo/antlr-interest">http://www.antlr.org/mailman/listinfo/antlr-interest</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/options/antlr-interest/your-email-address">http://www.antlr.org/mailman/options/antlr-interest/your-email-address</a>

  

        
      </blockquote>

List: <a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/listinfo/antlr-interest">http://www.antlr.org/mailman/listinfo/antlr-interest</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/options/antlr-interest/your-email-address">http://www.antlr.org/mailman/options/antlr-interest/your-email-address</a>

  

    </blockquote>

------------------------------------------------------------------------

_______________________________________________
antlr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:antlr-dev@...">antlr-dev@...</a>
<a class="moz-txt-link-freetext" href="http://www.antlr.org/mailman/listinfo/antlr-dev">http://www.antlr.org/mailman/listinfo/antlr-dev</a>

  </blockquote>

  
</blockquote>
<br>
</div>
Terence Parr | 9 Apr 2009 22:37
Gravatar

fixed some stuff

April 9, 2009

* .g and .g3 file extensions work again.
* introduced bug in 3.1.3: gives exception not error msg upon
   missing .g file

Ter
Jim Idle | 10 Apr 2009 16:08

C# runtime version

Anyone know why the version that can be downloaded from the web site is 
3.1.2? IS there not a 3.1.3 for C#?

Jim
Jim Idle | 10 Apr 2009 17:34

C# 2 target and import grammars

Anyone know how to specify or otherwise make work, import grammars in C# 
2 target 3.1.3?

If I specify a  <at> namespace in the base grammars then it can't find the 
delegators in the generated code for the imports. If I don't specify any 
namespaces at all then it seems to try to use the name of my grammar for 
a type, which it cannot then find . If I add the  <at> namespace option to 
all the grammars including the import grammars, then the main code 
cannot find the delegates.

I can't seem to work out what the correct combination is. Anyone got any 
docs or can give me a hint here?

Jim
Sam Harwell | 10 Apr 2009 17:41

Re: C# 2 target and import grammars

This is specific to the C# *3* target but shows how I'm currently
working to address this issue.

Delegate grammars currently don't work quite right in the C# 3 target.
Since each grammar type is declared as a 'partial class', I'm
implementing the delegator classes within the grammar they are delegated
to.

GrammarParser.cs:

namespace GrammarNamespace {
public partial class Grammar1 : Parser { ... }
}

GrammarParser.IncludedGrammarParser.cs:

namespace GrammarNamespace {
partial class Grammar1 {
partial class IncludedGrammarParser : Parser { ... }
}
}

-----Original Message-----
From: antlr-dev-bounces@... [mailto:antlr-dev-bounces@...]
On Behalf Of Jim Idle
Sent: Friday, April 10, 2009 10:35 AM
To: ANTLR-dev Dev
Subject: [antlr-dev] C# 2 target and import grammars

Anyone know how to specify or otherwise make work, import grammars in C#

2 target 3.1.3?

If I specify a  <at> namespace in the base grammars then it can't find the 
delegators in the generated code for the imports. If I don't specify any

namespaces at all then it seems to try to use the name of my grammar for

a type, which it cannot then find . If I add the  <at> namespace option to 
all the grammars including the import grammars, then the main code 
cannot find the delegates.

I can't seem to work out what the correct combination is. Anyone got any

docs or can give me a hint here?

Jim
_______________________________________________
antlr-dev mailing list
antlr-dev@...
http://www.antlr.org/mailman/listinfo/antlr-dev
John Lynn | 10 Apr 2009 19:30
Picon

Getting off the ground with a new target

Hello - I followed all of the steps in "How to build an ANTLR code
generation target" (at least I think I did), but when I give it a go
(on Windows) against a grammar file "T.g":

java -classpath "C:\AntlrV3\antlr-3.1\lib\antlr-3.1.jar"
"org.antlr.Tool"  "C:\AntlrV3\antlr-3.1\runtime\XYZ\T.g"

the result is:

ANTLR Parser Generator  Version 3.1 (August 12, 2008)  1989-2008
error(10):  internal error: no such group file XYZ.stg
error(20):  cannot find code generation templates XYZ.stg

I copied Java.stg to XYZ.stg which is sitting in a directory
"C:\AntlrV3\antlr-3.1\src\org\antlr\codegen\templates"

Do I need to invoke java while in a particular directory? How is
antlrV3 looking for the .stg file?

Thanks...
Sam Harwell | 10 Apr 2009 19:52

Ummmmmm Perforce? Wow...

Lets you check in a folder and a file with the same name?

 

How can I make it not allow a particular file to ever be checked in (exclusion by name)? I tried checking in a folder with the same name as the file, then deleting it from disk and putting a file there instead, and it let me check in that file without even a warning.

 

Thanks,

Sam Harwell

 

<div>

<div class="Section1">

<p class="MsoNormal">Lets you check in a folder and a file with the same name?<p></p></p>

<p class="MsoNormal"><p>&nbsp;</p></p>

<p class="MsoNormal">How can I make it not allow a particular file to ever be
checked in (exclusion by name)? I tried checking in a folder with the same name
as the file, then deleting it from disk and putting a file there instead, and it
let me check in that file without even a warning.<p></p></p>

<p class="MsoNormal"><p>&nbsp;</p></p>

<p class="MsoNormal">Thanks,<p></p></p>

<p class="MsoNormal">Sam Harwell<p></p></p>

<p class="MsoNormal"><p>&nbsp;</p></p>

</div>

</div>
Sam Harwell | 10 Apr 2009 20:03

Re: Ummmmmm Perforce? Wow...

I checked in 2 empty dummy files, I created a separate client spec where I locked them... I guess that works.

 

Sam

 

From: antlr-dev-bounces-ErkRXerACLvYtjvyW6yDsg@public.gmane.org [mailto:antlr-dev-bounces-ErkRXerACLvYtjvyW6yDsg@public.gmane.org] On Behalf Of Sam Harwell
Sent: Friday, April 10, 2009 12:53 PM
To: ANTLR-dev Dev
Subject: [antlr-dev] Ummmmmm Perforce? Wow...

 

Lets you check in a folder and a file with the same name?

 

How can I make it not allow a particular file to ever be checked in (exclusion by name)? I tried checking in a folder with the same name as the file, then deleting it from disk and putting a file there instead, and it let me check in that file without even a warning.

 

Thanks,

Sam Harwell

 

<div>

<div class="Section1">

<p class="MsoNormal"><span>I checked in 2 empty dummy files,
I created a separate client spec where I locked them... I guess that works.<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>Sam<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<div>

<div>

<p class="MsoNormal"><span>From:</span><span>
antlr-dev-bounces@... [mailto:antlr-dev-bounces@...] On Behalf
Of Sam Harwell<br>Sent: Friday, April 10, 2009 12:53 PM<br>To: ANTLR-dev Dev<br>Subject: [antlr-dev] Ummmmmm Perforce? Wow...<p></p></span></p>

</div>

</div>

<p class="MsoNormal"><p>&nbsp;</p></p>

<p class="MsoNormal">Lets you check in a folder and a file with the same name?<p></p></p>

<p class="MsoNormal"><p>&nbsp;</p></p>

<p class="MsoNormal">How can I make it not allow a particular file to ever be
checked in (exclusion by name)? I tried checking in a folder with the same name
as the file, then deleting it from disk and putting a file there instead, and
it let me check in that file without even a warning.<p></p></p>

<p class="MsoNormal"><p>&nbsp;</p></p>

<p class="MsoNormal">Thanks,<p></p></p>

<p class="MsoNormal">Sam Harwell<p></p></p>

<p class="MsoNormal"><p>&nbsp;</p></p>

</div>

</div>

Gmane