Example #1
0
    static FSMPage Parse(string path, System.Type handleType)
    {
        string text = (Resources.Load(path) as TextAsset).text;
        text = RemoveBlockComments(text);
        string[] lines = text.Split("\n".ToCharArray(), System.StringSplitOptions.None);

        FSMPage page = new FSMPage();
        List<string> paragraph = null;
        TagMethodTable methodTable = new TagMethodTable(handleType);
        foreach (var entity in lines)
        {
            string line = entity.Trim();
            if (line.StartsWith("//"))
            {
                continue;
            }

            if (line.Contains(":="))
            {
                string[] keyValue = line.Split(new string[] { ":=", " ", }, System.StringSplitOptions.RemoveEmptyEntries);
                methodTable.RegistFunction(keyValue[0], keyValue[1]);
                continue;
            }

            if (!string.IsNullOrEmpty(line))
            {
                if (paragraph == null)
                {
                    paragraph = new List<string>();
                }
                paragraph.Add(line);
                continue;
            }

            if (string.IsNullOrEmpty(line))
            {
                if (paragraph != null)
                {
                    page.Add(new FSMParagraph(paragraph.ToArray(), methodTable));
                    paragraph = null;
                }
                continue;
            }
        }

        return page;
    }
Example #2
0
File: FSM.cs Project: pb0/ID0_Test
 static FSM()
 {
     internalMethods = new TagMethodTable(null);
     internalMethods.RegistFunction<FSM>(FSMKeywords.FuncLog, "Log");
 }