Path: news.daimi.aau.dk!olm From: olm@daimi.aau.dk (Ole Lehrmann Madsen) Newsgroups: comp.lang.beta Subject: Re: Extensions to the Beta Grammar Date: 12 Feb 1997 21:23:03 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 44 Message-ID: <5dtcbn$rvc$1@gjallar.daimi.aau.dk> References: <3301C7BF.1C3A@daimi.aau.dk> NNTP-Posting-Host: clematis.daimi.aau.dk X-Newsreader: NN version 6.5.1 (NOV) Xref: news.daimi.aau.dk comp.lang.beta:10963 In <3301C7BF.1C3A@daimi.aau.dk> J|rg Olaf Schneider writes: >While experimenting with extensions to the Beta grammar, I observed that >the bobsit tool concludes, that the Beta grammar is not LALR(1). This >implies that I can't generate a correct parser for an extended Beta >grammar. Can anybody tell me, why the Beta grammar is not LALR(1), as >required by the metaprogramming system. The grammar used is in >'~beta/grammars/beta/v2.5'. How do I fix this? The reported LALR(1) conflict is due to conflicts between so-called error productions. Error productons are used by the parser to recover after syntax errors in the input string. The reported conflict is harmless and a parser is in fact constructed. (I think that the message from bobsit actually says that a parser is constructed?) BOBS always constructs a parser, even when there are LALR-conflicts. When a conflict is met during parsing, a choice is made between one of the conflicts. If the conflict is due to a simple ambiguity this will work. If the conflict is not a simple ambiguity but the choice depends on input symbols further ahead in input the choice may be wrong and a parse error is reported. It could be fixed if the parser did some backtracking, but this is not the case. In general, of course, one should fix LALR-conflicts, since the parser may otherwise be incorrect. However for simple ambiguities, the paser may be OK. To decide this may be hard unless you are familiar with LALR-grammars. As said, the reported conflicts for the BETA grammar are harmless. I hope this helps. It is difficult explaining LALR-parse theory in a message like this. I will be happy to give a more detailed explanation if you come by my office:-) ---olm >-- Jorg >------------------------------------------------------------------- >/ Jorg Schneider, Computer Science Department, Aarhus University / >/ Ny Munkegade 116, Bld. 540, DK-8000 Aarhus C, DENMARK / >/ Email: josch@daimi.aau.dk / >/ WWW: http://www.daimi.aau.dk/~josch / >-------------------------------------------------------------------