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 x need to have property isinarg True() and False(), respectively. AST-wise there is no difference between x : Int and y : Int and introducing an abstract syntax difference for them is not an option.

Because the isinarg property 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: Boolean

Then during a pre-analysis phase annotate argument declaration with an annotation to indicate whether isinargs is supposed to be true/false. Then during analysis create isinarg-is tasks 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())> name

I 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)> name still 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

On 10 December 2013 at 17:52 Guido Wachsmuth commented:

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:

  1. Calculate the property of a term with a task.

      create-yourprop-task(|ctx): ... -> <yourprop-is(|ctx)> ...
    
  2. Associate a name with that property, quering the property from the term in a where clause.

      ...: defines Namespace name of yourprop p where ... has yourprop p
    

On 10 December 2013 at 21:24 Vlad Vergu commented:

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 be True() for those arguments. The arguments mentioned after the ; should have the property False().

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 as in |[ name : type ]| and out |[ name : type ]|.

  1. i’ve done that as shown in OP
  2. 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 isin
    

I hope this helps to clarify the issue.


On 11 December 2013 at 11:46 Vlad Vergu commented:

Any clues?


On 19 January 2014 at 00:39 Guido Wachsmuth commented:

Is this currently working in Greenmarl?


On 19 January 2014 at 09:59 Vlad Vergu commented:

Yes. This is working since Jan 15 in GM.


On 19 January 2014 at 09:59 Vlad Vergu closed this issue.

Log in to post comments