[antlr-interest] Beginner needing help with rewrite rules
Jim Idle
jimi at temporal-wave.com
Tue Oct 18 14:11:06 PDT 2011
Looks like you need:
group : (OPEN
space*
(
sg=group space* |
p=plaintext space* |
((c1=command)+ space) |
(e=escape) space*
)+
((c2=command)+)?
CLOSE) -> ^(GROUP ^(GROUP $sg)* $p+ $c1+ $e+ $c2+)
At a rough guess.
Jim
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Yves Weißig
> Sent: Tuesday, October 18, 2011 12:11 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Beginner needing help with rewrite rules
>
> Hi ANTLR list,
> I'm using ANTLR within my master's thesis in order to parse the RTF
> file format. Everything is fine so far, I can parse simple RTF
> documents. The next step is to generate an AST. Here is where the
> problems start, it seems as if I have an error in one of my rewrite-
> rules. If you look at the grammar, what I want to do, is nest the
> groups. This means, a "group" is child of a "group" if the subrule
> group in the rule group is
> called: sg=group space* -> ^(GROUP $sg+). Maybe you try the grammar
> using a simple RTF snippet, e.g.
> {\pard\fs32\b NOTES\par}
> {\pard\fs26 Recently I skimmed {\i Structure and Interpretation of
> Computer Programs}, by Sussman and Abelson, and I think there should
> have been more pictures.
> \line I like pictures. Is that so na\'efve?
> \par}
> from: http://search.cpan.org/~sburke/RTF-Writer/lib/RTF/Cookbook.pod
> Do you have any comments or ideas what I'm doing wrong?
> Best regards, Yves
More information about the antlr-interest
mailing list