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()); }
public GUINodeParameter(BTLTokenizer.Token token) { var v = BTLTokenizer.ParseParameter(token); value = token.content; _type = v.GetType(); }
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)); } } } } }
public override string ToString() { string str = ""; if (type == TokenType.Word) { str = content; } else if (type == TokenType.EOL) { str = "[EOL]\n"; } else if (type == TokenType.Value) { str = BTLTokenizer.ParseParameter(this).ToString(); } else { str = string.Format("[{0}]", type.ToString()); } return(str); }
private static string GetTreeName(Node tree) { return(BTLTokenizer.ParseParameter(tree.parameters[0]).ToString()); }