コード例 #1
0
        public static TypeNode Create(LeafParser.Def_typeContext ctx)
        {
            var s = ctx.@struct();

            if (s != null)
            {
                return(new StructTypeNode(s));
            }
            throw new NotImplementedException();
        }
コード例 #2
0
        private void DefineType(LeafParser.Def_typeContext def, LeafParser.Attribute_addContext[]?attribs)
        {
            Type type;
            var  name = def.Id().GetText();

            if (def.generic_def_list() != null)
            {
                throw new NotImplementedException("Generics are not supported.");
            }

            if (def.@struct() != null)
            {
                type = new StructType(name, this, def.@struct(), attribs);
            }
            else
            {
                throw new NotImplementedException();
            }

            if (!Namespace.Types.TryAdd(name, type))
            {
                throw new DuplicateSymbolException(name, this, def.Start.Line);
            }
        }
コード例 #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="LeafParser.def_type"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitDef_type([NotNull] LeafParser.Def_typeContext context)
 {
     return(VisitChildren(context));
 }