/// <summary>
        /// Type declaration entry.
        ///
        /// DECLARE IDENTIFIER generic_type_attributes? '{' operation_statement+ '}'
        /// </summary>
        /// <param name="context"></param>
        public override void EnterType_declaration(KryptonParser.Type_declarationContext context)
        {
            var parent = _memberContainers.Peek();

            TypeDeclarationBase declared;
            var name = context.IDENTIFIER().GetText();

            // Verify our name is unique
            if (parent.TryFindMember(name, out var _))
            {
                throw new KryptonParserException($"Multiple definitions for {name}.");
            }

            // Declare a generic if we have attributes
            var generics = context.generic_type_attributes()?.IDENTIFIER();

            if (generics != null)
            {
                var generic = new GenericTypeDeclaration(name, parent);
                foreach (var g in generics)
                {
                    var t = new GenericAttribute(g.GetText());
                    generic.AddGeneric(t);
                }
                declared = generic;
            }
            else
            {
                declared = new TypeDeclaration(name, parent);
            }

            parent.AddMember(declared);
            _statementContainers.Push(declared);
            _documentables.Push(declared);
        }
Esempio n. 2
0
 public override INode VisitGenericTypeDeclaration(GenericTypeDeclaration genericTypeDeclaration)
 {
     return(new GenericTypeDeclaration(genericTypeDeclaration.Context, genericTypeDeclaration.Name, genericTypeDeclaration.Children.Select(Visit)));
 }
Esempio n. 3
0
 public virtual void ExitGenericTypeDeclaration(GenericTypeDeclaration genericTypeDeclaration)
 {
 }
Esempio n. 4
0
 public virtual T VisitGenericTypeDeclaration(GenericTypeDeclaration genericTypeDeclaration)
 {
     return(VisitChildren(genericTypeDeclaration));
 }