コード例 #1
0
ファイル: ScriptApp.cs プロジェクト: androdev4u/XLParser
    public ParseTree LastScript { get; private set; } //the root node of the last executed script


    #region Constructors
    public ScriptApp(LanguageData language) {
      Language = language;
      var grammar = language.Grammar as InterpretedLanguageGrammar;
      Runtime = grammar.CreateRuntime(language);
      DataMap = new AppDataMap(Language.Grammar.CaseSensitive); 
      Init(); 
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: androdev4u/XLParser
 static void Main(string[] args) {
   Console.Title = "Irony Console Sample";
   Console.WriteLine("Irony Console Sample.");
   Console.WriteLine("");
   Console.WriteLine("Select a grammar to load:");
   Console.WriteLine("  1. Expression Evaluator");
   Console.WriteLine("  2. mini-Python");
   Console.WriteLine("  Or press any other key to exit.");
   Console.WriteLine("");
   Console.Write("?");
   var choice = Console.ReadLine();
   Grammar grammar; 
   switch (choice) {
     case "1": 
       grammar = new SampleExpressionEvaluatorGrammar();
       break;
     case "2":
       grammar = new MiniPython.MiniPythonGrammar();
       break; 
     default:
       return;
   }
   Console.Clear();
   var language = new LanguageData(grammar);
   var runtime = new LanguageRuntime(language);
   var commandLine = new CommandLine(runtime);
   commandLine.Run();
 }
コード例 #3
0
ファイル: ScriptApp.cs プロジェクト: dbremner/irony
 public ScriptApp(LanguageRuntime runtime)
 {
     Runtime = runtime;
       Language = Runtime.Language;
       DataMap = new AppDataMap(Language.Grammar.CaseSensitive);
       Init();
 }
コード例 #4
0
ファイル: ScriptInterpreter.cs プロジェクト: cg123/xenko
 public ScriptInterpreter(LanguageData language) {
   Language = language;
   Runtime = Language.Grammar.CreateRuntime(Language);
   Parser = new Parser(Language);
   EvaluationContext = new EvaluationContext(Runtime);
   Status = _internalStatus = InterpreterStatus.Ready;
 }
コード例 #5
0
 public ScriptApp(LanguageRuntime runtime)
 {
     Runtime  = runtime;
     Language = Runtime.Language;
     DataMap  = new AppDataMap(Language.Grammar.CaseSensitive);
     Init();
 }
コード例 #6
0
 public ScriptInterpreter(LanguageData language)
 {
     Language          = language;
     Runtime           = Language.Grammar.CreateRuntime(Language);
     Parser            = new Parser(Language);
     EvaluationContext = new EvaluationContext(Runtime);
     Status            = _internalStatus = InterpreterStatus.Ready;
 }
コード例 #7
0
        }                                             //the root node of the last executed script


        #region Constructors
        public ScriptApp(LanguageData language)
        {
            Language = language;
            var grammar = language.Grammar as InterpretedLanguageGrammar;

            Runtime = grammar.CreateRuntime(language);
            DataMap = new AppDataMap(Language.Grammar.CaseSensitive);
            Init();
        }
コード例 #8
0
ファイル: EvaluationContext.cs プロジェクト: cg123/xenko
 public EvaluationContext(LanguageRuntime runtime) {
   Runtime = runtime;
   LanguageCaseSensitive = Runtime.Language.Grammar.CaseSensitive;
   //Globals = new GlobalValuesTable(100, Symbols, LanguageCaseSensitive);
   Globals = new ValuesTable(100);
   CallDispatcher = new DynamicCallDispatcher(this);
   ThreadId = Thread.CurrentThread.ManagedThreadId;
   TopFrame = new StackFrame(this, Globals);
   CurrentFrame = TopFrame;
   Data = new DataStack();
   Data.Init(runtime.Unassigned); //set LastPushedItem to unassigned
 }
コード例 #9
0
 public EvaluationContext(LanguageRuntime runtime)
 {
     Runtime = runtime;
     LanguageCaseSensitive = Runtime.Language.Grammar.CaseSensitive;
     //Globals = new GlobalValuesTable(100, Symbols, LanguageCaseSensitive);
     Globals        = new ValuesTable(100);
     CallDispatcher = new DynamicCallDispatcher(this);
     ThreadId       = Thread.CurrentThread.ManagedThreadId;
     TopFrame       = new StackFrame(this, Globals);
     CurrentFrame   = TopFrame;
     Data           = new DataStack();
     Data.Init(runtime.Unassigned); //set LastPushedItem to unassigned
 }
コード例 #10
0
ファイル: CommandLine.cs プロジェクト: MarcusTheBold/Irony
 public CommandLine(LanguageRuntime runtime, IConsoleAdaptor console = null)
 {
     Runtime = runtime;
       _console = console ?? new ConsoleAdapter();
       var grammar = runtime.Language.Grammar;
       Title = grammar.ConsoleTitle;
       Greeting = grammar.ConsoleGreeting;
       Prompt = grammar.ConsolePrompt;
       PromptMoreInput = grammar.ConsolePromptMoreInput;
       App = new ScriptApp(Runtime);
       App.ParserMode = ParseMode.CommandLine;
       // App.PrintParseErrors = false;
       App.RethrowExceptions = false;
 }
コード例 #11
0
        public CommandLine(LanguageRuntime runtime, IConsoleAdapter console = null)
        {
            Runtime  = runtime;
            _console = console ?? new SystemConsoleAdapter();
            var grammar = runtime.Language.Grammar;

            Title           = grammar.ConsoleTitle;
            Greeting        = grammar.ConsoleGreeting;
            Prompt          = grammar.ConsolePrompt;
            PromptMoreInput = grammar.ConsolePromptMoreInput;
            App             = new ScriptApp(Runtime);
            App.ParserMode  = ParseMode.CommandLine;
            // App.PrintParseErrors = false;
            App.RethrowExceptions = false;
        }
コード例 #12
0
        public CommandLine(LanguageRuntime runtime, IConsoleAdapter adapter)
        {
            Runtime = runtime;
            Adapter = adapter ?? new ConsoleAdapter();
            var grammar = runtime.Language.Grammar;

            Title           = grammar.ConsoleTitle;
            Greeting        = grammar.ConsoleGreeting;
            Prompt          = grammar.ConsolePrompt;
            PromptMoreInput = grammar.ConsolePromptMoreInput;
            App             = new ScriptApp(Runtime)
            {
                ParserMode        = ParseMode.CommandLine,
                RethrowExceptions = false
            };
            // App.PrintParseErrors = false;
        }
コード例 #13
0
ファイル: MrtParser.cs プロジェクト: Kintaro/Hyperion
        /// <summary>
        ///
        /// </summary>
        /// <param name="sceneFile">
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        public bool Parse(string sceneFile)
        {
            Console.WriteLine ("  > Invoking Parser:");
            Console.WriteLine ("    - Reading file {0}", sceneFile);
            Irony.Parsing.LanguageData languageData = new Irony.Parsing.LanguageData (_grammar);
            Irony.Parsing.Parser parser = new Irony.Parsing.Parser (languageData);
            LanguageRuntime runtime = new LanguageRuntime (languageData);

            System.Text.StringBuilder builder = new System.Text.StringBuilder ();
            System.IO.StreamReader reader = System.IO.File.OpenText (sceneFile);
            builder.Append (reader.ReadToEnd ());

            Console.WriteLine ("    - Parsing contents");
            ParseTree tree = parser.Parse (builder.ToString ());
            Console.WriteLine ("    - Status: {0}", tree.Status);
            var node = tree.Root.AstNode as AstNode;
            node.Evaluate (new EvaluationContext (runtime), AstMode.Read);

            return true;
        }
コード例 #14
0
        public static void Main(string[] args)
        {
            Console.Title = "Ftp Irony Console Sample";
            Console.WriteLine("Ftp Irony Console Sample.");
            Console.WriteLine(string.Empty);
            Grammar grammar = new FtpGrammar();
            var language = new LanguageData(grammar);
            var runtime = new LanguageRuntime(language);

            Parser parser = new Parser(grammar); // necessário

            while (true)
            {
                Console.Write("AZFTP> ");
                string input = Console.ReadLine();
                ParseTree tree = parser.Parse(input + System.Environment.NewLine);

                // notajota: the interpretation of the input command must be externalized and uniformized to transform the Ast into service calls
                // if command was recognized
                if (tree.ParserMessages.Count == 0)
                {
                    if (tree.Root.ChildNodes[0].ChildNodes[0].ChildNodes[0].Term.Name == "byeCommand")
                    {
                        return;
                    }
                }

                Console.WriteLine("## parser messages: " + tree.ParserMessages.Count);
                foreach (LogMessage lm in tree.ParserMessages)
                {
                    Console.WriteLine("## parser messages: " + lm.Message);
                }

                Console.WriteLine("## parser time (ms): " + tree.ParseTimeMilliseconds);
            }
        }
コード例 #15
0
 public DynamicCallDispatcher(EvaluationContext context)
 {
     _context = context;
     _runtime = _context.Runtime;
     OperatorImplementations = _runtime.CreateOperatorImplementationsTable();
 }
コード例 #16
0
 public ScriptThread(ScriptApp app) {
   App = app;
   Runtime = App.Runtime;
   CurrentScope = app.MainScope;
 }
コード例 #17
0
 public ScriptThread(ScriptApp app)
 {
     App          = app;
     Runtime      = App.Runtime;
     CurrentScope = app.MainScope;
 }
コード例 #18
0
 public CommandLine(LanguageRuntime runtime)
     : this(runtime, null)
 {
 }