[antlr-interest] Noob Question

Martin Jacobson jacobson.martin at gmail.com
Fri Jul 2 06:22:12 PDT 2010


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


More information about the antlr-interest mailing list