[antlr-interest] Simple Grammar Problem
Brian Geffon
briangeffon at gmail.com
Sat Sep 10 11:41:30 PDT 2011
Hi,
I'm using antlr 3 and I'm trying to create a simple grammar, a simple
example is below, I'm trying to allow for any text but embedded within
it some special tags. I'm calling the arbitary text with no tags
embedded a buffer, in addition i'm trying to support loop tags,
partial tags, and comments. So a valid input might be:
{#loop1}{>partial1}Blah BlAh! Test{#loop2}foo{/loop2}{/loop1}, but I'm
having trouble with the arbitrary text in between tags. Do I have to
create a lexer rule like '\u0000'..'\uFFFF' for it to work, because
that seems a little crazy to have to do that. Thanks in advance.
Brian
grammar Dust;
options {
language=Java;
}
start : body EOF;
body : (loop | partial | buffer)*
;
loop : '{#' IDENT '}'
body
'{/' IDENT '}'
;
partial : '{>' IDENT '}'
;
buffer : ~('{' | EOF)+;
foo : COMMENT;
IDENT : 'a'..'z'+;
COMMENT : '{!' .* '!}'
;
More information about the antlr-interest
mailing list