Search code examples
rascal

Alternative implementation of the @src and @decl annotations in the M3 model


"...all nodes have a src annotation to point to the physical source location, all declarations may have a decl annotation to their logical location identifier..." is a line taken from the paper: M3: a General Model for Code Analytics in Rascal.

However, when creating a new M3 model for a relatively simple language, where all source code elements have their own naming scheme, and all the types of the elements are explicitly defined in the AST, therefore not having to resolve their types seperately. Would it then be considered "ok" to ditch the physical source code location, place the logical source code location in the @src annotation, since for all nodes a logical source code can be created, and just not use the @decl annotation? Would this be considered a bad implementation of the M3 model or would it be fine because the simple language allows for such a simplification of the implementation of the M3 model?

Because otherwise all nodes would get a @src with the physical source code location, and a @decl with a logical source code location, cluttering the AST while a single logical source code location would suffice.


Solution

  • That is an excellent question. I think the current set of IDE tools or other tools I know of would not break if you do not put a @src annotation. So in that sense nothing bad happens.

    What would be bad is not having the source locations in the M3 declarations table. So if you can produce this table without having the annotations on the AST, then your fine.

    Soon the M3 model will move to using keyword fields and then we could even introduce a default implementation which resolves src to decl if it's not there.

    So, why not try out your suggestion and see where it fails? If we end up needing the @src later, it wouldn't be so hard to add it back right!