コード例 #1
0
ファイル: TotemContext.cs プロジェクト: Alxandr/Totem-2.0
        public override ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
        {
            try
            {
                switch (sourceUnit.Kind)
                {
                    case SourceCodeKind.SingleStatement:
                    case SourceCodeKind.Expression:
                    case SourceCodeKind.AutoDetect:
                    case SourceCodeKind.InteractiveCode:
                        return new TotemScriptCode(
                            engine, engine.ParseExprToLambda(sourceUnit),
                            sourceUnit);

                    //case SourceCodeKind.Statements:
                    //case SourceCodeKind.File:
                    //    return new TotemScriptCode(
                    //        engine, engine.ParseFileToLambda(sourceUnit.Path, sourceUnit.GetCode()),
                    //        sourceUnit);

                    default:
                        throw Assert.Unreachable;
                }
            }
            catch (Exception e)
            {
                // Real language implementation would have a specific type
                // of exception.  Also, they would pass errorSink down into
                // the parser and add messages while doing tighter error
                // recovery and continuing to parse.
                errorSink.Add(sourceUnit, e.Message, SourceSpan.None, 0,
                              Severity.FatalError);
                return null;
            }
        }
コード例 #2
0
 public override void Add(SourceUnit source, string /*!*/ message, SourceSpan span, int errorCode, Severity severity)
 {
     CountError(severity);
     _sink.Add(source, message, span, errorCode, severity);
 }
コード例 #3
0
ファイル: CompilerContext.cs プロジェクト: tylike/IronScheme
 public void AddError(string message, SourceLocation start, SourceLocation end, Severity severity, int errorCode)
 {
     _errors.Add(SourceUnit, message, new SourceSpan(start, end), errorCode, severity);
 }