![]() |
|
Navigation |
Synopsis Convert a Pico parse tree into a Pico abstract syntax tree.
Examples The mapping between parse tree and abstract sybtax tree is achieved as follows:
module demo::lang::Pico::Load import Prelude; import demo::lang::Pico::Syntax; import demo::lang::Pico::Abstract; public PROGRAM load(str txt) = implode(#PROGRAM, parse(#Program, txt));Notes:
load can be used as follows:
rascal>import demo::lang::Pico::Load; ok rascal>load("begin declare x : natural; x := 3 end"); PROGRAM: program( [decl( "x", natural()[ @location=|file://-|(18,7,<1,18>,<1,25>), @comments=() ])[ @location=|file://-|(14,11,<1,14>,<1,25>), @comments=() ]], [asgStat( "x", natCon(3)[ @location=|file://-|(32,1,<1,32>,<1,33>), @comments=() ])[ @location=|file://-|(27,6,<1,27>,<1,33>), @comments=() ]])[ @location=|file://-|(0,37,<1,0>,<1,37>), @comments=() ]Observe how the various parts of the abstract syntax tree are annotated with location attributes. ![]() |