Code Fragments of Parse::RecDescent

805 Words Feb 19th, 2018 3 Pages
Since Parse::RecDescent is recursive descent, and therefore goes depth first left-to-right, I think that'd work in one pass.

I'm sure this is S-attributed. (Attribute rules for things on the left depend only on things on the right, i.e. their direct children, so bottom-up works.) Turns out its also L-attributed
(top-down left-to-right has what's needed in order) which is I believe what Parse::RecDescent needs to do it in one pass. See abc_2.pl for a Parse::RecDescent for that version.

But here I'm doing something conceptually simpler, I think, though it does require more code. First I'm using Parse::RecDesent's <autotree> feature to generate a parse tree, and then once its in hand I'm explicitly applying an attribute grammar at each node using a depth-first…
Open Document