Exemplo n.º 1
0
 public override object VisitTypeDecl([NotNull] SLangGrammarParser.TypeDeclContext context)
 {
     checkDefinitions[context.Id().GetText()] = true;
     currentType = Table.FindClass(ModuleData.Name, context.Id().GetText()).TypeIdent;
     base.VisitTypeDecl(context);
     currentType = null;
     return(null);
 }
        public override object VisitTypeDecl([NotNull] SLangGrammarParser.TypeDeclContext context)
        {
            var className = context.Id().GetText();

            ThrowIfReservedWord(className, ModuleData.File, context.Id().Symbol);

            if (moduleTable.Classes.ContainsKey(className))
            {
                ThrowClassRedefinitionException(className, ModuleData.File, context.Id().Symbol);
            }

            var isBase   = context.Base() != null;
            var modifier = GetModifierByName(context.AccessModifier().GetText());

            var classItem = new ClassNameTableItem {
                TypeIdent = new SlangCustomType(ModuleData.Name, className), CanBeBase = isBase, Column = context.Id().Symbol.Column, Line = context.Id().Symbol.Line, AccessModifier = modifier
            };

            moduleTable.CheckCommonNamesConflicts(classItem.TypeIdent.Name, classItem.Line, classItem.Column);
            moduleTable.Classes[className] = classItem;
            return(base.VisitTypeDecl(context));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="SLangGrammarParser.typeDecl"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitTypeDecl([NotNull] SLangGrammarParser.TypeDeclContext context)
 {
 }
 /// <summary>
 /// Visit a parse tree produced by <see cref="SLangGrammarParser.typeDecl"/>.
 /// <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 VisitTypeDecl([NotNull] SLangGrammarParser.TypeDeclContext context)
 {
     return(VisitChildren(context));
 }