public override object VisitModule([NotNull] SLangGrammarParser.ModuleContext context)
        {
            var moduleToken = context.Id().Symbol;
            var moduleName  = context.Id().GetText();

            ThrowIfReservedWord(moduleName, ModuleData.File, moduleToken.Line, moduleToken.Column);

            if (moduleName != ModuleData.Name)
            {
                ThrowModuleNameConflictFileNameException(moduleName, ModuleData.Name, ModuleData.File, moduleToken);
            }

            if (moduleName != CompilerConstants.MainModuleName && context.moduleStatementsSeq() != null)
            {
                ThrowEntryPointException(moduleName, ModuleData.File, context.moduleStatementsSeq().Start().Symbol);
            }
            if (moduleName == CompilerConstants.MainModuleName && context.moduleStatementsSeq() == null)
            {
                ThrowEntryPointMainException(ModuleData.File, context.Id().Symbol);
            }

            if (context.Empty() != null)
            {
                moduleTable.IsEmpty = true;
            }

            return(base.VisitModule(context));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="SLangGrammarParser.module"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitModule([NotNull] SLangGrammarParser.ModuleContext context)
 {
 }
 /// <summary>
 /// Visit a parse tree produced by <see cref="SLangGrammarParser.module"/>.
 /// <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 VisitModule([NotNull] SLangGrammarParser.ModuleContext context)
 {
     return(VisitChildren(context));
 }