0

I'm working with TatSu, and the results I get from the codegen parser is very different from the one I get from when the parser is build directly. Consider the fairly simple grammar for dice notation:

start = expression $;

int = /-?\d+/ ;

dice = number_of_dice:factor /d|D/ sides:factor;

expression = addition ;

addition
    =
    | left:addition op:('+' | '-') ~ right:addition
    | dice_expr
    ;

dice_expr
    =
    | dice
    | factor
    ;

factor
    =
    | '(' ~ @:expression ')'
    | int
    ;

Then if I feed 1d3 to the parser generated via tatsu.compile I get the result I'd expect:

{'number_of_dice': '1', 'sides': '3'}

However, when I use the parser generated vita the TatSu command line tool, I get:

{'left': None, 'op': None, 'right': None}

I've tried separating out the rules, combining the rules, etc. The only way I can get it to work is by breaking statements like (1+2)d3 break. Is there something I'm missing?

  • If this problem is still present, could you post an [issue](https://github.com/neogeny/TatSu/issues) against TatSu? The grammar is left recursive, and a resolution step may be missing in the generated parser. – Apalala Mar 16 '21 at 14:50
  • I posted the issue. Please feel free to follow up there. It would be good to know how you invoked the command-line tool. https://github.com/neogeny/TatSu/issues/180 – Apalala Mar 16 '21 at 15:18
  • I'll be honest, I switched to a different tool, so I'm not sure if it's still present or not – Brendan McGloin Mar 17 '21 at 17:07

1 Answers1

1

This issue is solved in the latest version of TatSu: https://pypi.org/project/tatsu/

Apalala
  • 9,017
  • 3
  • 30
  • 48