[antlr-interest] Re: RTF spec/grammar in (E)BNF

lgcraymer lgc at mail1.jpl.nasa.gov
Tue Nov 5 15:22:26 PST 2002


--- In antlr-interest at y..., "gudnabrsam" <gudnabrsam at y...> wrote:
> Does anyone have an opinion on how hard it would be to arrange the 
> BNF-based contents of this document into an ANTLR grammar?
> 
> -Matt
> 
> --- In antlr-interest at y..., "kresimir_saric" <kresimir.saric at b...> 
> wrote:
> > You can find v1.7 of RTF spec in .DOC format on www.wotsit.org

I gave Spenser Kao the following advice for the 1.6 spec from 
microsoft.com (html):

------------------------------------------------------------------
If you look at the "header" and "document" sections, you will find a 
complete EBNF grammar in unconventional format:

<ruleName>       rule definition

and continuation lines start with an indent.

If you convert the "header" and "Document area" sections to text, you 
should be able to
1.)  extract lines beginning with < and continuation lines for 
rules--you should be able to write a simple ANTLR grammar to skip 
anything that's not a rule and convert the rules to an ANTLR parser 
grammar.

2.)  extract all commands--tokens beginning with \ --to a file.  You 
can build a symbol table with either my rtftable tool or something 
equivalent.

You'll then have to do something about numerical arguments on 
commands--the "N"s--but that should be minor.

-------------------------------------------------------------

Looking at the 1.7 spec, it is possible to directly convert it to text 
and then process it, but that's a little messy.  It looks better to go 
through the document and manually convert each table to text (via the 
"convert to" item on the table menu), then convert the document to 
.txt format and do the above processing.

It should not take more than a few days to develop the filter grammars 
to extract a full RTF .g grammar.  Spenser mentioned a 1.8 version of 
the spec, and I suspect that it is easier to develop the filters for 
the spec itself rather than converting the JavaCC grammar, and the 
filters can be reused for new versions of the spec.

--Loring


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list