Related articles |
---|
grammar/dialect question wlhst6+@pitt.edu (W. Lyle Hayhurst) (1999-11-23) |
Re: grammar/dialect question wlhst6+@pitt.edu (W. Lyle Hayhurst) (1999-11-23) |
From: | "W. Lyle Hayhurst" <wlhst6+@pitt.edu> |
Newsgroups: | comp.compilers |
Date: | 23 Nov 1999 00:40:10 -0500 |
Organization: | University of Pittsburgh |
Keywords: | parse, question, comment |
Hi. I have a question about grammars and language dialects. I am
working on a grammar to lex && parse a certain railroad computer
protocol ( BR1810 ). This protocol has evolved over the years into at
least 3 unoffical, but used, dialects.
I want to incorporate these dialects into my canonical BR1810 grammar.
Hence, my question: can dialects be integrated into the standard
grammar of a language, or do you have to write an entirely seperate
grammar for each dialect?
Thanks !!
Lyle
[Depends how different they are. If they're only slightly different, you
can often fudge it with semantic checks. If they're really different, you
can use fake or variant tokens to guide the parser, e.g., if you have three
versions, OLD, MIDDLE, and NEW, you could write this:
program:
OLD old-program
| MIDDLE middle-program
| NEW new-program ;
old-program: ...
middle-program: ...
new-program: ...
and have the lexer return a magic token at the beginning to tell the parser
what to do. Note that the three variants can share internal rules for stuff
thats' the same. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.