Stratego/XT JIRA  History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: STR-577
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Martin Bravenboer
Reporter: Martin Bravenboer
Votes: 0
Watchers: 0
Operations

Clone this issue
Create sub-task
If you were logged in you would be able to see more operations.
Stratego/XT

Stratego: support import of an ATerm from a file

Created: 2006-05-30 15:04   Updated: 2008-03-31 20:44
Component/s: Language concepts
Affects Version/s: 0.16 (Stratego Core Compiler)
Fix Version/s: 0.17

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description  « Hide
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.


 All   Comments   Work Log   Change History      Sort Order:
Eelco Visser [2006-09-05 10:41]
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.)

Martin Bravenboer [2006-11-26 22:47]
Current implementation does not work. Needs to be checked why and fixed. Assigning to me.

Martin Bravenboer [2007-01-05 17:49]
pack-stratego does not qualify the file name of the imported term :(

Martin Bravenboer [2007-01-05 18:09]
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.

Martin Bravenboer [2007-01-05 18:16]
parse-stratego is the wrong place for this: it should happen in pack-stratego.