[antlr-interest] Noob Question
Martin Jacobson
jacobson.martin at gmail.com
Fri Jul 2 06:57:19 PDT 2010
There you go! I knew it had to be something really dumb!
Thanks, it now generates code!
M
On 2 July 2010 14:51, Mikesell, Darin B. <Darin.Mikesell at gd-ais.com> wrote:
> All your rules are setup as Lexer rules in your grammar. Just remember, in ANTLR, Parser rules start with a lower case letter; you just need to change the first letter to lowercase in all your Parser rules.
>
>
> - Darin
>
>
>
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Martin Jacobson
> Sent: Friday, July 02, 2010 6:22 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Noob Question
>
> I suspect the error message is too generic to be useful for a noob like me!
> I am trying to parse SVG <path> data and create "Geometry" objects
> (using the JTS library) - I have a working, but limited parser that I
> hand-coded, and a Java-CUP/JFlex version that has serious issues
> surrounding Classpaths. I have started to look at ANTLR, and produced
> the following in ANTLRWorks...
>
> ========================== begin ==============
> grammar PathParser;
>
> INT : '0'..'9'+
> ;
>
> FLOAT
> : ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
> | '.' ('0'..'9')+ EXPONENT?
> | ('0'..'9')+ EXPONENT
> ;
>
> WS : ( ' '
> | '\t'
> | '\r'
> | '\n'
> )* {$channel=HIDDEN;}
> ;
>
> fragment
> EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
>
>
> CmdM : 'M' FLOAT ','? FLOAT LineArgs?;
> Cmdm : 'm' FLOAT ','? FLOAT LineArgs?;
>
> LineArgs
> : (FLOAT ','? FLOAT)+;
>
> CmdL : 'L' LineArgs;
> Cmdl : 'l' LineArgs;
>
> CmdZ : 'Z'|'z';
>
> MoveDrawCmd
> : CmdM Cmdm* (CmdL|Cmdl)* CmdZ?;
>
> PathParser
> : MoveDrawCmd+;
> ========================end=====================
>
> I also don't know whether/how to indicated that whitespace is allowed,
> but optional between lexer tokens.
>
> Thanks for any insights!
> Martin
>
> On 2 July 2010 13:50, Bart Kiers <bkiers at gmail.com> wrote:
>> Hi Martin,
>> On Fri, Jul 2, 2010 at 2:35 PM, Martin Jacobson <jacobson.martin at gmail.com>
>> wrote:
>>>
>>> I have the following error:
>>>
>>> /Users/martin/ANTLR/SVG/PathParser.g:0:0: syntax error: codegen:
>>> <AST>:0:0: unexpected end of subtree
>>>
>>> What does this indicate?
>>
>> Not sure. If, after search the below link, you're still stuck, could you
>> post the grammar?
>>
>>>
>>> Is there a searchable archive I can trawl through?
>>
>> Yes: http://antlr.markmail.org/
>> Regards,
>> Bart Kiers.
>
>
>
> --
> From my MacBook Pro
>
> 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
>
--
>From my MacBook Pro
More information about the antlr-interest
mailing list