Task

How to obtain abstract syntax trees

Description

Given a concrete term over some language L, an abstract syntax tree for that term is obtained by:

  1. generating a parse table from the grammar of L
  2. parsing the concrete term using this parse table
  3. imploding the parse tree to an abstract syntax tree
In order for the parse tree implosion to work properly, the grammar of L should be annotated with cons(...) attributes.

Examples

Assuming L.def is a grammar for L, and term.l is a concrete term over language L, an abstract syntax tree is obtained as follows: # sdf2table -i L.def -o L.tbl # sglr -p L.tbl -i term.l -o term.l.asfix # implode-asfix -i term.l.asfix -o term.l.ast

See also

ImplodeAsFix?, sglrSGLR, Sdf.Sdf2TablePGEN.

Revision: r1.4 - 10 Feb 2004 - 09:14 - MartinBravenboer
Tools > HowToObtainAbstractSyntaxTrees
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback