table infrastructures
play

Table Infrastructures 27th October 2015 Katrin Hlldobler, Pedram - PowerPoint PPT Presentation

Adaptable Symbol Table Management by Meta Modeling and Generation of Symbol Table Infrastructures 27th October 2015 Katrin Hlldobler, Pedram Mir Seyed Nazari, and Bernhard Rumpe Software Engineering RWTH Aachen University


  1. Adaptable Symbol Table Management by Meta Modeling and Generation of Symbol Table Infrastructures 27th October 2015 Katrin Hölldobler, Pedram Mir Seyed Nazari, and Bernhard Rumpe Software Engineering RWTH Aachen University http://www.se-rwth.de/

  2. Chair of Software Engineering Motivation RWTH Aachen University Slide 2  Many textual software languages share common concepts • Define model elements • Refer to model elements defined in the same model as well as in another model (including loading of models) • Shadow names that are already defined  Mechanisms behind those concepts usually are complex and must be fully understood by language engineer in order to apply them  Therefore, language workbenches provide mechanisms to implement those concepts  The MontiCore language workbench uses so-called symbol tables

  3. Chair of Software Engineering Symbol Tables RWTH Aachen University Slide 3  A symbol table is a data structure that maps names to their associated information.  In MontiCore, a symbol table may also represent the semantic meta model and contain information not directly defined in the model • e.g., all non-private fields of a Java class including fields of the super class

  4. Chair of Software Engineering Contribution RWTH Aachen University Slide 4  Language-independent meta model (M3) for symbol tables which is basis for language-specific symbol tables (M2)  An integration of the symbol table M3 model and the grammar M3 model, which allows to switch between both models as needed  The generation of the language specific symbol table and automatically integration with the grammar model grammar describing «M3» meta meta level grammars «instance» grammar e.g., for Java «M2» meta level «instance» model e.g., Java class «M1» model level «instance» «M0» system level e.g., CRM-system system

  5. Chair of Software Engineering Symbols: Named Model Elements RWTH Aachen University Slide 5 class C { kind 1 * CD SymbolKind Symbol named int f; «M3» elements C c; «instance» «instance» «instance» «instance» «M2» kind 1 * JClassSymbolKind void m() { JClassSymbol int f = g; kind 1 * JFieldSymbolKind JFieldSymbol while (…) { int f; } }  A symbol represents a named model element and its associated } information  It may provide information that is not (directly) contained in the model element  e.g., all non-private methods of the super class

  6. Chair of Software Engineering Scopes: Containers for Symbols RWTH Aachen University Slide 6 subs class C { CD * enclosingScope int f; «interface» 0..1 «M3» Symbol Scope * 1 enclosing C c; 1 spans ScopeSpanningSymbol void m() { 0..1 int f = g; «instance» while (…) { «M2» JClassSymbol int f; } if scope } method scope }  A scope holds a collection of symbol definitions class scope  Structured hierarchically  Limits visibility of a symbol  Some symbols span a scope (scope spanning symbols)

  7. Chair of Software Engineering Shadowing and Visibility Scopes RWTH Aachen University Slide 7 subs class C { CD * enclosingScope int f; «interface» 0..1 «M3» Symbol * 1 Scope C c; enclosing shadows field f void m() { ShadowingScope VisibilityScope int f; «instance» «instance» while (…) { int f; «M2» JClassScope } «instance» not allowed, } JMethodScope JWhileScope local variable } already defined  Shadowing scopes may shadow names of enclosing scopes, visibility scopes may not

  8. Chair of Software Engineering Symbol References RWTH Aachen University Slide 8 reference * * class C { CD Symbol SymbolReference definition int f; «M3» 0..1 * C c; refers to «M2» «instance» class “C” «instance» «instance» definition JClassSymbol JClassSymbolReference void m() { 0..1 * reference int f; 1 JFieldSymbol * while (…) { int f; } refers to } built-in type “ int ” }  A symbol reference refers to a symbol defined elsewhere either in the same model or another

  9. Chair of Software Engineering Simplified Grammar M3 Model RWTH Aachen University Slide 9  Textual software languages are described by grammars  Abstract syntax tree is the meta-model (instance of) Annotation JClass@Ann = "class" Name "{" (JField | JMethod)* "}"; JField = type:Name Name ";" ; (instance of) Nonterminal (instance of) (instance of) (instance of) Terminal Production Production CD Production «M3» 1 definedBy * * * * Terminal Nonterminal Annotation

  10. Chair of Software Engineering Composing Grammar and Symbol Table M3 Models RWTH Aachen University Slide 10  Language engineer (LE) usually needs both M2 models  To enable this, we compose the M3 models  LE can switch between these structures as needed CD Grammr M3-model Symbol Table M3-model «M3» SymbolKind 1 kind subs * * 1 * enclosingScope * * * 0..1 «interface» Production Symbol * Scope spannedScope enclosing 1 * 0..1 def definedBy 1 * 0..1 * * * ScopeSpanningSymbol Terminal Nonterminal Annotation VisibilityScope ShadowingScope ref * * * * SymbolReference ArtifactScope

  11. Chair of Software Engineering Generating Language-Specific Symbol Table (M2) RWTH Aachen University Slide 11 Language- specific symbol table depends on the language’s  semantic  Composition of the two M2 models is affected both the grammar design as well as the symbol table design  Hence, composition must be conducted manually  Generative support • Prerequisite: limit cardinalities to 0..1 • Automatically derive the language-specific symbol table infrastructure (or parts of it) from the grammar • Simultaneously integrate it with language-specific grammar model • Using annotation mechanism of MontiCore’s grammar

  12. Chair of Software Engineering Generating Language-Specific Symbol Table RWTH Aachen University Slide 13  Mapping via naming convention • production Prod is mapped to symbol Prod Symbol JClass @! = "class" Name "{" (JField | JMethod)* "}"; JField @! = type:Name @JClass Name ";" ; JWhile = "while" "(" ... ")" "{" JField* ... "}"; generate spans 1 1 1 kind CD * JClassSymbolKind JClassScope JClassSymbol «M2» 0..1 0..1 * JClassSymbolReference 1 * kind 1 * * JFieldSymbolKind JFieldSymbol * JWhileScope 0..1

  13. Chair of Software Engineering Conclusion RWTH Aachen University Slide 14  Textual software languages share some common concepts, such as defining and referencing model elements, and name shadowing  Language-independent meta model for symbol tables first-level classes, which serves as basis for language-specific symbol tables  Integration of this the symbol table meta model and the grammar meta model  Generating language-specific symbol table infrastructure (or parts of it) and directly integrating it with the corresponding grammar model

Recommend


More recommend