19 Apr 2007 01:53
Planning Project to use YAPP - confused on AST Tree Walker
I've been seeking a suitable XML format and supporting toolset to
store both an abstract grammar and the mapping from an instance of
the grammar (abstract syntax tree) to executable programs in a target
language.
I'm aiming to learn the basics of compiler design by re-creating a
subset of ECMAScript, (control flow, arithmetic and boolean logic),
but where the javascript is written from an abstract syntax tree
(AST) stored in XML directly e.g.
<if>
<equals>
<sum>
<number>2</number>
<number>2</number>
</sum>
<number>4</number>
</equals>
<assign>
<property>world</property>
<string>consistent</string>
</assign>
</if>
The grammar (also represented in XML, as in the case of YAPP) should
ensure that the original tree is indeed a valid construct, and
traversing the tree should spit out ECMAscript, in this example...
if(2 + 2 == 4){
world = 'consistent';
(Continue reading)
RSS Feed