On Tue, 12 Dec 2006, Hans Aberg wrote: > [Please try to give descriptive subjects; replies should cc the Help-Bison > list.] > > On 12 Dec 2006, at 12:28, [EMAIL PROTECTED] wrote: > > > I'm working on a prototype of a COBOL-parser in bison using a GLR-parser. > > I have a question considering YYABORT: > > When the parsing-process uses more then one parser, and one of them > > encounters this macro, will only this parser stop, or all of them. And if > > the second is the case, is there a way to accomplish the first? > > The first case. You can check out, in the parser that Bison writes, what the > macro does: it just jumps to a place where parser is terminated.
No, it's the second case. Maybe there's a confusion in terminology here: YYABORT stops the single GLR parser (that is, yyparse). There is no mechanism for stopping just one of the child LALR(1) parsers via semantic actions. The problem is that no semantic actions are actually performed until only one of these parsers is left. The other parsers are eliminated by true syntax errors (not YYERROR), %dprec, or %merge. In the case of %merge, the semantic actions recorded for each child parser will be performed. In the semantic actions where you were planning to invoke YYABORT, you could return some sort of NULL value and write your %merge functions to discard NULL children. I've not used this approach myself, but one caveat I'm aware of is that it's not always clear where the parser will choose to try a merge. _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison