cgen-aterm (stratego-libraries/build-tools) is currently used to generate a C file that produces a given ATerm. This might become more and more common when we are going to introduce more library, so this might be useful as a language feature (suggested by Eelco Visser). Something like this:

get-pp-table =
import(relative path to aterm in file)

The Stratego compiler will then read the ATerm file and generate the code to build the ATerm at runtime.

Submitted on 30 May 2006 at 17:04

On 5 September 2006 at 12:41 Jira commented:

STR-577, visser:
STR-577: support import of an ATerm from a file

New construct in Stratego for declaring the import of a term from a
file at compile-time.

M stratego-front/syn/Stratego-Core-Identifiers.sdf
M stratego-front/syn/Stratego-Core-Strategies.sdf
M stratego-front/pp/Stratego-Sugar-pretty.pp
M stratego-front/pp/Stratego-pretty.pp
M stratego-front/parse/stratego2abox.str

Syntax and pretty-printing

 import-term(./test104.trm)

where ‘import-term’ is a reserved keyword.

A strc-core/spec/test1/test104.trm
M strc-core/spec/test1/test104.str

The test

M c-tools/syn/Stratego-C.sdf

Antiquote for Initializer

M stratego-front/parse/parse-stratego.str

In the front-end the filename is qualified using the
include path passed to the compiler.

M strc-core/lib/stratego/strc/c/s2c-ng.str
M strc-core/lib/Makefile.am

In the back-end the aterm file is actually imported and translated to
a C function that reconstructs the term at run-time from an in-core
representation of the term in a string in BAF format. The conversion
from string to term is cached, so happens only once per execution.

(For large constant terms that are embedded in the code, this
representation may be preferable over the sequence of function calls
that used currently; so the importing of the term and generation of
the function for it might have to be separated. In fact, it might be
useful to have construct constant-term(t) that builds a literal term,
instead of making it into a term pattern; could be used instead as
optimization instead of current constant term caching in the
back-end.)


On 26 November 2006 at 23:47 Jira commented:

STR-577, martin:
Current implementation does not work. Needs to be checked why and fixed. Assigning to me.


On 5 January 2007 at 18:49 Jira commented:

STR-577, martin:
pack-stratego does not qualify the file name of the imported term :(


On 5 January 2007 at 19:09 Jira commented:

STR-577, martin:
parse-stratego does this (now fixed). An additional problem is that stratego-libraries uses sglri, not parse-stratego so impo-term is not handled. Need to fix this one way or another.


On 5 January 2007 at 19:16 Jira commented:

STR-577, martin:
parse-stratego is the wrong place for this: it should happen in pack-stratego.

Log in to post comments