コード例 #1
0
ファイル: Script.cs プロジェクト: M-gen/AssistVRoid
        public string GetCommandString(ScriptLineToken t, int index)
        {
            string v = t.command[index];

            v = TrimString(v);
            return(v);
        }
コード例 #2
0
ファイル: Script.cs プロジェクト: M-gen/AssistVRoid
 void Run_OneLine(ScriptLineToken t)
 {
     if (sub_line_analyze != null)
     {
         if (sub_line_analyze(t))
         {
             return;                      // true が帰ってきてるので、処理済みとして扱う
         }
     }
 }
コード例 #3
0
ファイル: Script.cs プロジェクト: M-gen/AssistVRoid
        public void Run(string function_name)
        {
            if (!token_def_function_top.ContainsKey(function_name))
            {
                return;                                                     // 存在しない
            }
            ScriptLineToken t_head = token_def_function_top[function_name];

            if (t_head == null)
            {
                return;
            }

            var             counter_stack = new List <int>();
            int             counter       = 0;
            ScriptLineToken t_pos         = t_head.token_code_tree[counter];

            counter++;

            while (t_pos != null)
            {
                switch (t_pos.command[0])
                {
                //case "$":
                //    Console.WriteLine(ExpansionString(t_pos.command));
                //    break;
                default:
                    Run_OneLine(t_pos);
                    break;
                }

                if (counter >= t_head.token_code_tree.Count())
                {
                    if (t_pos.parent.parent == null)
                    {
                        t_head = null;
                        t_pos  = null;
                    }
                    else
                    {
                        counter = counter_stack[0]; counter_stack.RemoveAt(0);
                        t_pos   = t_head.token_code_tree[counter];
                        counter++;
                    }
                }
                else
                {
                    t_pos = t_head.token_code_tree[counter];
                    counter++;
                }
            }
        }
コード例 #4
0
ファイル: Script.cs プロジェクト: M-gen/AssistVRoid
        public Script(string script_path, ScriptLineAnlyze sub_line_analyze = null)
        {
            this.script_path      = script_path;
            this.sub_line_analyze = sub_line_analyze;

            // スクリプトの単純な読み込み(トークン分けはおおなう)
            var file = new System.IO.StreamReader(script_path);

            string line;
            var    i = 0;

            while ((line = file.ReadLine()) != null)
            {
                var t = new ScriptLineToken();
                t.command      = SplitScriptLine(line);
                t.line_index   = i;
                t.owner_script = this;
                tokens.Add(t);

                i++;
            }
            file.Close();

            // 構造を分析してツリー構造へ(処理順を実行時に解釈・処理しやすくする)
            var             parent_token_stack = new List <ScriptLineToken>();
            ScriptLineToken parent_token       = null;

            foreach (var t in tokens)
            {
                if (t.command.Count() == 0)
                {
                    continue;
                }


                switch (t.command[0])
                {
                case "def":     // 関数の定義開始宣言
                    token_def_function_top.Add(t.command[1], t);
                    if (parent_token != null)
                    {
                        parent_token_stack.Clear();
                    }
                    parent_token = t;
                    parent_token.token_code_tree = new List <ScriptLineToken>();
                    break;

                default:
                    if (parent_token != null)
                    {
                        t.parent = parent_token;
                        parent_token.token_code_tree.Add(t);
                    }
                    else
                    {
                        // err
                    }
                    break;
                    //case "$":
                    //    break;
                }
            }
        }
コード例 #5
0
ファイル: Script.cs プロジェクト: M-gen/AssistVRoid
 public int GetCommandInt(ScriptLineToken t, int index)
 {
     return(int.Parse(t.command[index]));
 }