Example #1
0
        public ChapterSymbol?LookupChapter(Spanned <string> identifier)
        {
            ChapterSymbol?chapter = _module.LookupChapter(identifier.Value);

            if (chapter is not null)
            {
                return(chapter);
            }

            ReportUnresolvedIdentifier(identifier);
            return(null);
        }
Example #2
0
        public ChapterSymbol?ResolveCallChapterTarget(CallChapterStatement callChapterStmt)
        {
            string modulePath = callChapterStmt.TargetModule.Value;

            try
            {
                SourceModuleSymbol targetSourceModule = _compilation.GetSourceModule(modulePath);
                ChapterSymbol?     chapter            = targetSourceModule.LookupChapter("main");
                if (chapter is null)
                {
                    Report(callChapterStmt.TargetModule, DiagnosticId.ChapterMainNotFound);
                }
                return(chapter);
            }
            catch (FileNotFoundException)
            {
                string moduleName = callChapterStmt.TargetModule.Value;
                Report(callChapterStmt.TargetModule, DiagnosticId.ExternalModuleNotFound, moduleName);
                return(null);
            }
        }