/* (c) https://github.com/MontiCore/monticore */ package de.monticore.symbols; /* This is a MontiCore stable grammar. * Adaptations -- if any -- are conservative. */ import de.monticore.symbols.*; /** * The grammar introduces reusable symbols for * OOTypes, * Methods, and * Fields * which are specializations of the alredy defined * symbols from BasicSymbols.mc4 * * This grammar is used to generate an abstract syntax * (and especially symboltable infrastructure) only. * These AST-classes are then used to store typing information * in the SymbolTable. * * Here we mainly add the possibilities to store static, private, etc. flags * and extend the signature of methods for elliptic extensibility. * These extensions are rather common in OO (and especially Java-like) * languages. * * These symbols can be used elsewhere when actual implementations * of these symbols become available. * * A symboltable can export these symbols, while they are imported * (and thus used) as their more abstract counterparts from BasicSymbols. * */ component grammar OOSymbols extends BasicSymbols { /*=================================================================*/ /** * A type (in an OO sense) has a name, * methods, fields, supertypes. * * It may also contain potentially fields and OO methods. * These are represented as Symbols in the body of the type * and thus made available through the associated scope object. * * The new symbol OOTypeSymbol mainly adds OO specific properties. * */ interface scope symbol OOType extends Type = Name ; symbolrule OOType = isClass: boolean isInterface: boolean isEnum: boolean isAbstract: boolean isPrivate: boolean isProtected: boolean isPublic: boolean isStatic: boolean isFinal: boolean ; /*=================================================================*/ /** * A Field (local variable, method parameter, Java attribute) has a type * and a visibility. It may also be used in isolation (static). * * The new symbol FieldSymbol inherits from VariableSymbol * and mainly adds OO specific properties. */ interface symbol Field extends Variable = Name ; symbolrule Field = isPrivate: boolean isProtected: boolean isPublic: boolean isStatic:boolean isFinal: boolean isDerived: boolean ; /*=================================================================*/ /** * A Method has a return type, and a list of parameters, which * are stored as field symbols. * * The new symbol MethodSymbol inherits from FunctionSymbol and * mainly adds OO specific properties. */ interface symbol Method extends Function = Name ; symbolrule Method = isConstructor: boolean isMethod: boolean isPrivate: boolean isProtected: boolean isPublic: boolean isAbstract: boolean isStatic: boolean isFinal: boolean ; }