dino-lang / dino

The programming language DINO
GNU General Public License v2.0
71 stars 5 forks source link

MSTA: small inconsistency wrt to yacc behaviour #18

Open rofl0r opened 4 years ago

rofl0r commented 4 years ago

bison and byacc both assign default action { $$ = $1; } to expression as below:

mnemonic: MN_JMP
 | MN_JZ
 | MN_JNZ
 ;

so that the result is identical to

mnemonic: MN_JMP { $$ = $1; }
 | MN_JZ   { $$ = $1; }
 | MN_JNZ   { $$ = $1; }
 ;

MSTA instead (even in yacc mode) creates different, incompatible (and quite big) piece of code for every line in the expression. i'm not sure whether this is documented behaviour, but it'd be nice to have it supported when using MSTA as yacc replacement.

vnmakarov commented 4 years ago

OK. Thanks for reporting this. I designed this code 30 years ago and there are a lot of optimizations in the parser, especially for rule reductions and attribute passing. So the code you see might be an optimized version of the code for parsing by several rules. I'll investigate this when I have time.