librelist archives

« back to archive

[ruby.parslet] Left recursion

[ruby.parslet] Left recursion

Chris Corbyn
2011-11-04 @ 15:28
In reply to:

I just got the following working fine:


{:multiply=>{:left=>{:int=>"2"@0}, :right=>{:sum=>{:left=>{:int=>"2"@4}, 

And re-associating it as:

{:sum=>{:left=>{:multiply=>{:left=>{:int=>"2"@0}, :right=>{:int=>"2"@4}}},

I'd like to make this generic, such that you can basically flag rules as 
left or right associative, inside the parser (left(:rule) vs. 
right(:rule)) and have #parse pass its result through a Transformation 
that is based on which rules have been marked as having different 

I'll post back if I come up with anything.