Re: [cedet-semantic] Is there a wisent analog to Bison %empty non-empty rule?
Brought to you by:
zappo
From: Christian J. <chr...@cv...> - 2020-06-16 09:21:01
|
Hi, I found a work-around that seems to work in Wisent, just start grammar with %empty: () ; and the parser doesn't complain anymore on any %empty usage in grammar. I'm working on a Elisp tool that converts GNU Bison / YACC grammar into Wisent Elisp. The trickies parts are solved, at least for my usage, converting C into Elisp (from the offical PHP YACC grammar). I have some smaller items left before it's done though. https://github.com/cjohansson/emacs-wisent-grammar-converter Best regards Christian On 16/06/2020 02:46, Eric Ludlam wrote: > I wasn't familiar with %empty, but based on what I read for bison, you > can just omit it. Even in bison, you need a special flag in order to > get warnings indicating you need to add the %empty in. > > Hopefully that works for you. I haven't done any coding in this tool > in a long time and am not the original wisent author either. :( > > Eric > > On 6/14/20 5:32 PM, Christian Johansson wrote: >> Hi Eric! >> >> Alright, I don’t just want to create tags, I would like to build a >> complete AST equivalent of the PHP AST. Can you improve the Wisent >> parser to fully support GNU Bison? Or is there a work-around I can >> use to make the gramnar work? >> >> Ideally I would like to spot code parser errors in Elisp without >> having to run the code via a PHP runtime executable. >> >> Best regards >> Christian >> >> 14 juni 2020 kl. 22:21 skrev Christian Johansson <chr...@cv... >> <mailto:chr...@cv...>>: >> >>> Hi Eric! >>> >>> Alright, I don’t just want to create tags, I would like to build a >>> complete AST equivalent of the PHP AST. Can you improve the Wisent q >>> >>>> 13 juni 2020 kl. 21:36 skrev Eric Ludlam <er...@si... >>>> <mailto:er...@si...>>: >>>> >>>> Hi Christian, >>>> >>>> Using %prec, etc doesn't occur much in Wisent grammars because the >>>> usual use case is to generate tags, and not evaluate code that >>>> requires precedence. If your goal is to just generate tags, there >>>> is a good chance you can just ignore the %prec pieces of the rule. >>>> If the precedence is not used in expressions used after an equal, >>>> then you may be able to just delete the whole rule backup_fn_flags. >>>> >>>> A quick read of bison %empty indicates it can be safely left out as >>>> well, so if you need to keep the rule, just delete %empty. >>>> >>>> Hope this helps. >>>> Eric >>>> >>>>> On 6/6/20 1:47 AM, Christian Johansson wrote: >>>>> Hi! >>>>> I'm translating the PHP bison grammar to wisent and currently I'm >>>>> stuck at a rule that looks like this: >>>>> backup_fn_flags: >>>>> %prec PREC_ARROW_FUNCTION %empty { $$ = CG(extra_fn_flags); >>>>> CG(extra_fn_flags) = 0; } >>>>> ; >>>>> The %prec symbol seems to work with Wisent but for the %empty I >>>>> get the message "wisent-parse-nonterminals: Symbol ‘%empty’ is >>>>> used, but is not defined as a token and has no rules" >>>>> Is it possible to solve this? >>>>> For empty %empty rules I just replace %empty with ;; empty\n but I >>>>> don't know what to do when there are other nonterminals in the rule >>> >>> >>> >>> _______________________________________________ >>> cedet-semantic mailing list >>> ced...@li... >>> <mailto:ced...@li...> >>> https://lists.sourceforge.net/lists/listinfo/cedet-semantic |