Skip to content

Commit

Permalink
NodeWalker and removal of reduce()
Browse files Browse the repository at this point in the history
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
Marcel Laverdet committed Nov 19, 2010
1 parent 580ee8a commit c235a01
Show file tree
Hide file tree
Showing 6 changed files with 267 additions and 345 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@

Expand Down
1 change: 1 addition & 0 deletions TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cpp_library(
'parser.yy',
'node.cpp',
'parser.cpp',
'walker.cpp',
],
deps = [ ':libfbjs_support' ],
)
Expand Down
Loading

0 comments on commit c235a01

Please sign in to comment.