Skip to content

Latest commit

 

History

History
80 lines (62 loc) · 3.18 KB

File metadata and controls

80 lines (62 loc) · 3.18 KB

SymTabDefinition

MontiCore Symbol tables are stored as JSON artifacts. JSON symbol tables are not very concise, easy to read or write. As such, JSON symbol tables are best generated based on a model by a language tool.

SymTabDefinition is a small, non-conservative CD4Code variant for the modelling of symbol tables. Its models a concise, easily read- and writeable representation of symbol tables. The Current version focuses on types, functions, and variables. As its sole purpose is to describe symbol tables, elements that are not represented in the symbol table are not part of the language, e.g., initial values of variables/fields.

Example for SymTabDefinition

package de.monticore.math;

symtabdefinition Calc {
  
  double pi; 
  
  int abs(int i);
  
  class Vec2<T> {
    + T v1;
    + T v2;
    + (T, T) asTuple();
    + <U> Vec2<U> map(T -> U mapping);
  }

}

The example:

  • defines a variable symbol pi of type double.
  • defines a function symbol abs of type int -> int;
    • the parameter has name i.
  • defines a (generic) CDType symbol Vec2; In the spanned scope of the symbol are
    • a type-variable symbol T.
    • two public field symbols v1, v1, each of type T.
    • a public method symbol asTuple of type () -> (T, T).
    • a public generic method symbol map of type (T -> U) -> Vec2<U>;
      • the function parameter has the name mapping;
      • the type parameter has the name U;

Differences between SymTabDefinition and CD4Code

CD4Code has model elements that are not part of the SymTabDefinition Language

  • initial values for fields (and variables) are not stored in the symbol table, and as such are not part of the language.
  • Associations are not part of the SymTabDefinition language.

SymTabDefinition has model elements that are not part of CD4Code

Further Information