Example #1
0
        public CompilationException Add(SyntaxTree node)
        {
            CompilationException exception = new CompilationException();

            var(tree, formartter, errors) = node;


            exception.Formatter = formartter;
            exception.Diagnostics.AddRange(errors);


            if (exception.Diagnostics.Count != 0)
            {
                exception.ErrorFlag = CompileError.Syntax;
                exception.Message   = "语法错误,请仔细检查脚本代码!";
                NErrorLog log = new NErrorLog();
                log.Handler(exception.Diagnostics);
                if (NErrorLog.Enabled)
                {
                    log.Write();
                }
                exception.Log = log.Buffer.ToString();
            }
            else
            {
                TreeCodeMapping[tree]  = tree.ToString();
                TreeUsingMapping[tree] = default;
            }
            SyntaxExceptions.Add(exception);
            return(exception);
        }
Example #2
0
 public static void ErrorRecoder(CSharpCompilation compilation, List <CompilationException> exceptions)
 {
     if (NErrorLog.Enabled)
     {
         NErrorLog log = new NErrorLog();
         foreach (var item in exceptions)
         {
             log.Handler(compilation, item.Diagnostics);
         }
         log.Write();
     }
 }
Example #3
0
 public static void ErrorRecoder(params CompilationException[] exceptions)
 {
     if (NErrorLog.Enabled)
     {
         NErrorLog log = new NErrorLog();
         foreach (var item in exceptions)
         {
             log.Handler(item.Diagnostics);
         }
         log.Write();
     }
 }