示例#1
0
 private void _PutRuntime(ILanguageRuntime runtime)
 {
     if (m_singleThreaded)
     {
         m_runtimes.Add(runtime);
     }
 }
示例#2
0
        public Interpreter(object context, ILanguageRuntime language)
        {
            this.language = language;
            this.context  = context;
            this.logging  = new MemoryLogging();

            // Default behavior
            this.LoggingKind = LoggingKind.ThrowOnError;
        }
示例#3
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.language = null;
         this.context  = null;
         this.logging  = null;
     }
 }
        public static int IdentifySymbolValue(this ILanguageRuntime @this, object value)
        {
            if (value == null)
            {
                return(PredefinedTokens.Eoi);
            }

            return(@this.Identify(value.GetType()));
        }
示例#5
0
 private void Parse(ILanguageRuntime lang, string input)
 {
     using (var interp = new Interpreter(context, lang))
     {
         interp.LoggingKind = LoggingKind.Collect;
         interp.Parse(input);
         errorCount = interp.ErrorCount;
     }
 }
示例#6
0
        public Interpreter(object context, ILanguageRuntime language)
        {
            this.language = language;
            this.context = context;
            this.logging = new MemoryLogging();

            // Default behavior
            this.LoggingKind = LoggingKind.ThrowOnError;
        }
示例#7
0
        public void AsynHandler(int methodId, string input)
        {
            ILanguageRuntime runtime = null;

            try
            {
                runtime = _GetRuntime();
                runtime.AsynHandler(methodId, input);
            }
            finally
            {
                if (runtime != null)
                {
                    _PutRuntime(runtime);
                }
            }
        }
示例#8
0
        internal int LoadProgram(string file)
        {
            ILanguageRuntime runtime = null;

            try
            {
                runtime = _GetRuntime();
                return(runtime.LoadProgram(file));
            }
            finally
            {
                if (runtime != null)
                {
                    _PutRuntime(runtime);
                }
            }
        }
 private void Parse(ILanguageRuntime lang, string input)
 {
     using (var interp = new Interpreter(context, lang))
     {
         interp.LoggingKind = LoggingKind.Collect;
         interp.Parse(input);
         errorCount = interp.ErrorCount;
     }
 }
示例#10
0
 private static bool IsBootstrap(ILanguageRuntime result)
 {
     return(result is IBootstrapLanguage);
 }
示例#11
0
 public Interpreter(ILanguageRuntime language)
     : this(language.CreateDefaultContext(), language)
 {
 }
示例#12
0
        public static Msg Symbol <T>(this ILanguageRuntime @this, T value)
        {
            var id = @this.IdentifySymbolValue(value);

            return(new Msg(id, value, Loc.Unknown));
        }
示例#13
0
 public static Msg Symbol <T>(this ILanguageRuntime @this) where T : new()
 {
     return(@this.Symbol(new T()));
 }
示例#14
0
        public static Msg Literal(this ILanguageRuntime @this, string literal)
        {
            var id = @this.Identify(literal);

            return(new Msg(id, null, Loc.Unknown));
        }
示例#15
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.language = null;
         this.context = null;
         this.logging = null;
     }
 }
示例#16
0
 public Interpreter(ILanguageRuntime language)
     : this(language.CreateDefaultContext(), language)
 {
 }