4 ms·
thought it would be fun to write this in raku grammar Arithmetic { rule TOP { ^ <expr> $ } rule expr { <term>+ % ['+' | '-'] } r
by librasteve 1y ago
thought it would be fun to write this in raku
grammar Arithmetic {
rule TOP { ^ <expr> $ }
rule expr { <term>+ % ['+' | '-'] }
rule term { <value> }
rule value { <number> | <parens> }
rule number { \d+ }
rule parens { '(' <expr> ')' }
}