Attach property to name without NaBL
I need to attach a property to a Variable. The value of the property to attach cannot be specified in NaBL. How can I achieve this?
Example:
Proc a(x : Int; y : Int) { x = 42; y = 42; }Where
xneed to have propertyisinargTrue()andFalse(), respectively. AST-wise there is no difference betweenx : Intandy : Intand introducing an abstract syntax difference for them is not an option.Because the
isinargproperty is context-sensitive its value cannot be specified directly in NaBL. What i tried to do is declare the property in NaBL like so:properties isinarg of Variable: BooleanThen during a pre-analysis phase annotate argument declaration with an annotation to indicate whether
isinargsis supposed to betrue/false. Then during analysis createisinarg-istasks to the values stored as annotations in the pre-analysis phase. This is the implementation of the task creation:create-isinarg-task(|ctx): |[ name : type ]| -> <isinarg-is(|ctx)> <get-prop-anno(|DesugarIsinarg())> nameI have verified that the desugaring is correct and that the task is created successfully and annotated correctly on the AST. The problem is that any
<isinarg-lookup(|ctx)> namestill fails. The index does not contain any association of the property to the name.How do get this done?
Submitted by Vlad Vergu on 10 December 2013 at 17:30
Issue Log
Tasks are only associated with terms, never with names.
When should the value be
False()? Why can’t you desugar into a syntactic difference instead of an annotation?In general, the solution is as follows:
Calculate the property of a term with a task.
create-yourprop-task(|ctx): ... -> <yourprop-is(|ctx)> ...Associate a name with that property, quering the property from the term in a
whereclause....: defines Namespace name of yourprop p where ... has yourprop p
Hi Guido, thank you for your answer.
Yes indeed tasks are associated with terms. As i mentioned the property annotation looks fine.
In procedure arguments everything before the
;is an input argument and the property should beTrue()for those arguments. The arguments mentioned after the;should have the propertyFalse().I cannot desugar into a syntactic difference because that will break use concrete object syntax in transformations. Creating two really (in SDF) different AST constructs that correspond to the same concrete syntax pattern must unfortunately also be avoided. This is because all the existing transformations that match
|[ name : type ]|would need to be manually inspected for correctness (cannot be checked statically) and rewritten with a disambiguator such asin |[ name : type ]|andout |[ name : type ]|.
- i’ve done that as shown in OP
- this is where the problem is. I cannot attach the property to anything. I would have to write the following which is not syntactically allowed:
Arg([arg], t): defines Variable arg of isinarg isin where Arg([arg], t) has isinarg isinI hope this helps to clarify the issue.
Any clues?
Is this currently working in Greenmarl?
Yes. This is working since Jan 15 in GM.
Log in to post comments