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: [email protected] 
[mailto:[email protected]] On Behalf Of Martin Jacobson
Sent: Friday, July 02, 2010 6:22 AM
To: [email protected]
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 <[email protected]> wrote:
> Hi Martin,
> On Fri, Jul 2, 2010 at 2:35 PM, Martin Jacobson <[email protected]>
> 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

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to