[antlr-interest] Baffled using Antlr to parse custom markup language

Sam Kuper sam.kuper at uclmail.net
Thu Sep 24 18:10:28 PDT 2009


Here's my (grossly incomplete, but better than nothing) progress so far:

[BEGIN]
grammar name_reg;
options {
    language=Java;
}

name_reg    : ( options {greedy=false;} : . )* a_field b_field? c_field?
v_field? e_field? EOF;

a_field        : STAR_A '\\\\' name '\\\\ ' dateblock? description '('
sources ')' .* ;
name        : ( options {greedy=false;} : . )* ;
dateblock    : '(' dates '). ';
dates        : 'b. ' NUM NUM NUM NUM '/' NUM NUM;
description    : ~'(' ( options {greedy=false;} : . )* ;
sources        : ( options {greedy=false;} : . )* ;

b_field        : STAR_B .*;

c_field        : STAR_C .*;

v_field        : STAR_V .*;

e_field        : STAR_E .*;

STAR_A        : '*a ';
STAR_B        : '*b ';
STAR_C        : '*c ';
STAR_V        : '*v ';
STAR_E        : '*e ';
PUNCTUATION    : ' '|'.'|','|':'|'!'|'\n'|'('|')'|'-';
ALPHA        : 'a'..'z'|'A'..'Z';
NUM        : '0'..'9';
[END]

This is generating an error:

name_regParser.java:510: exception org.antlr.runtime.RecognitionException is
never thrown in body of corresponding try statement
        catch (RecognitionException re) {
        ^
1 error

I'd be grateful for help troubleshooting this error, so that I can continue
to work on the grammar above.

Many thanks,

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090925/c86cf449/attachment.html 


More information about the antlr-interest mailing list