Rule precedence issue with grako

前端 未结 2 1610
猫巷女王i
猫巷女王i 2021-01-14 14:39

I\'m redoing a minilanguage I originally built on Perl (see Chessa# on github), but I\'m running into a number of issues when I go to apply semantics.

Here is the gr

2条回答
  •  攒了一身酷
    2021-01-14 15:00

    The problem with your example is that Grako has the nameguard feature enabled by default, and that won't allow parsing just the d when d6 is ahead.

    To disable the feature, instantiate your own Buffer and pass it to an instance of the generated parser:

    from grako.buffering import Buffer
    from myparser import MyParser
    
    # get the text
    parser = MyParser()
    parser.parse(Buffer(text, nameguard=False), 'expre')
    

    The tip version of Grako in the Bitbucket repository adds a --no-nameguard command-line option to generated parsers.

提交回复
热议问题