public override object VisitType_declaration([NotNull] Type_declarationContext context) { var all_member_modifiers = context.all_member_modifiers(); HashSet <string> modifiers; if (all_member_modifiers != null) { modifiers = (HashSet <string>)Visit(all_member_modifiers); } else { modifiers = new HashSet <string>(); modifiers.Add("private"); } try { IdentifierContext identifier; if (context.class_definition() != null) { identifier = context.class_definition().identifier(); } else { identifier = context.struct_definition().identifier(); } var symbol = identifier.Symbol; symbol.SetModifiers(modifiers); } catch { } return(base.VisitType_declaration(context)); }
private void ParseTypeDeclaration(Type_declarationContext node) { Class_definitionContext classContext = node.class_definition(); Interface_definitionContext interfaceContext = node.interface_definition(); Delegate_definitionContext delegateContext = node.delegate_definition(); Enum_definitionContext enumContext = node.enum_definition(); bool isClass = classContext != null; bool isInterface = interfaceContext != null; bool isDelegate = delegateContext != null; bool isEnum = enumContext != null; string type = ""; string name = ""; if (isClass) { type = "Class"; name = this.GetNodeName(classContext.identifier()); } else if (isInterface) { type = "Interface"; name = this.GetNodeName(interfaceContext.identifier()); } else if (isDelegate) { type = "Delegate"; name = this.GetNodeName(delegateContext.identifier()); } else if (isEnum) { type = "Enum"; name = this.GetNodeName(enumContext.identifier()); } if (!string.IsNullOrEmpty(name)) { this.WriteLine(); this.WriteKeyValue(type, name); } if (isClass) { this.WriteBeginBrace(); this.ParseClassDeclaration(classContext); this.WriteEndBrace(); } else if (isInterface) { this.WriteBeginBrace(); this.ParseInterfaceDeclaration(interfaceContext); this.WriteEndBrace(); } }
public static Symbol Create([NotNull] Type_declarationContext context, ScopedSymbolTable scopedTable) { List <string> modifiers = new List <string>(); string symbolname = null; string fullName = null; List <DefinitionSymbol> baseTypes = new List <DefinitionSymbol>(); List <GenericInfo> genericParameters = new List <GenericInfo>(); var modifierContexts = context.all_member_modifiers()?.all_member_modifier(); foreach (var modifierCon in modifierContexts) { modifiers.Add(modifierCon.GetText()); } var classdefinition = context.class_definition(); symbolname = classdefinition.identifier().GetText(); fullName = scopedTable.Path + "." + symbolname; ClassSymbol classSymbol = new ClassSymbol(symbolname, fullName, modifiers); return(classSymbol); }
public override void EnterType_declaration(Type_declarationContext context) { throw new InternalParseException("Unsupported expression. ExpressionType=type declaration", context); }