Permalink
Browse files

NodeWalker and removal of reduce()

Summary:
A general solution is needed for walking these AST's and applying a transformation to them. This implements a typical visitor class from which you can extend to subscribe to nodes you want to handle. There's built-in methods for manipulating the tree as you go, and getting data from your children.

Test Plan:
Built a few walkers for another application, adapting this API as I found use cases.

Reviewed By: epriestley
  • Loading branch information...
1 parent 580ee8a commit c235a01d4d17b5de65e30cca627e302d1a4a20ad @laverdet laverdet committed Nov 19, 2010
Showing with 267 additions and 345 deletions.
  1. +2 −1 Makefile
  2. +1 −0 TARGETS
  3. +0 −329 node.cpp
  4. +44 −15 node.hpp
  5. +67 −0 walker.cpp
  6. +153 −0 walker.hpp
View
@@ -55,8 +55,9 @@ parser.yacc.o: parser.lex.hpp
parser.lex.o: parser.yacc.hpp
parser.o: parser.yacc.hpp
node.o: parser.yacc.hpp
+walker.o: node.hpp walker.hpp
-libfbjs.a: parser.yacc.o parser.lex.o parser.o node.o dmg_fp_dtoa.o dmg_fp_g_fmt.o
+libfbjs.a: parser.yacc.o parser.lex.o parser.o node.o walker.o dmg_fp_dtoa.o dmg_fp_g_fmt.o
$(AR) rc $@ $^
$(AR) -s $@
View
@@ -4,6 +4,7 @@ cpp_library(
'parser.yy',
'node.cpp',
'parser.cpp',
+ 'walker.cpp',
],
deps = [ ':libfbjs_support' ],
)
Oops, something went wrong.

0 comments on commit c235a01

Please sign in to comment.