Exemple #1
0
        public static BTLTokenizer.Token[][] Tokenize(string[] sources, string[] filepaths, ref PandaScriptException[] exceptions)
        {
            List <BTLTokenizer.Token[]> tokenSets = new List <BTLTokenizer.Token[]>();

            for (int i = 0; i < sources.Length; i++)
            {
                if (sources[i] == null)
                {
                    tokenSets.Add(null);
                    continue;
                }

                if (filepaths != null && i < filepaths.Length)
                {
                    BTLTokenizer.filepath = filepaths[i];
                }
                try
                {
                    tokenSets.Add(BTLTokenizer.Tokenize(sources[i]));
                }
                catch (PandaScriptException e)
                {
                    tokenSets.Add(null);
                    exceptions[i] = e;
                    Debug.LogError(e);
                }
            }

            return(tokenSets.ToArray());
        }
Exemple #2
0
        void Parse()
        {
            btnodes.Clear();
            Clear();

            BTLTokenizer.Token[] tokens = null;

            try
            {
                tokens = BTLTokenizer.Tokenize(content);
            }
            catch (PandaScriptException e)
            {
                Debug.LogException(e);
            }

            GUINode node = null;

            if (tokens != null)
            {
                foreach (var t in tokens)
                {
                    if (t.content == null)
                    {
                        continue;
                    }

                    string trimmed = t.content.Trim();
                    if (trimmed == "")
                    {
                        continue;
                    }
                    if (trimmed.StartsWith("//"))
                    {
                        node       = new GUINode(GUINode.NodeType.Comment);
                        node.label = "//";
                        string comment = trimmed.Substring(2, trimmed.Length - 2);
                        node.Parameters_Add(new GUINodeParameter(typeof(string), comment));
                        Nodes_Add(node);
                    }
                    else
                    if (IsLabel(t))
                    {
                        node = new GUINode(trimmed);
                        Nodes_Add(node);
                        node.line = this;
                    }
                    else
                    if (t.valueType != BTLTokenizer.TokenValueType.None)
                    {
                        if (node != null)
                        {
                            node.Parameters_Add(new GUINodeParameter(t));
                        }
                    }
                }
            }
        }