From eecaf63890a76503b5cd602e6b20b9c2f4ec7d99 Mon Sep 17 00:00:00 2001 From: xphlawlessx Date: Wed, 30 Sep 2020 23:37:33 +0100 Subject: [PATCH] Fixed a bug where the TestGrammar fires on AddComponent, and tested with 2019.4 LTS Unity version --- Source/Parser.cs | 3 +++ Source/Unity/GrammarEditor.cs | 4 ++-- Source/Unity/TraceryGrammar.cs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Parser.cs b/Source/Parser.cs index 116d4c4..b3953c5 100644 --- a/Source/Parser.cs +++ b/Source/Parser.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using UnityEngine; namespace Tracery { @@ -92,7 +93,9 @@ private ActionNode ParseAction() Advance(); } + string[] parts = builder.ToString().Split(new char[]{':'}, 2); + Assert.AreEqual(parts.Length, 2); // TODO allow function actions string key = parts[0]; NodeAction action; diff --git a/Source/Unity/GrammarEditor.cs b/Source/Unity/GrammarEditor.cs index 51941c3..8f5af5e 100644 --- a/Source/Unity/GrammarEditor.cs +++ b/Source/Unity/GrammarEditor.cs @@ -10,7 +10,7 @@ public class GrammarEditor : Editor { private int selected = 0; - private string testValue = null; + private string testValue =""; public override void OnInspectorGUI() { @@ -60,7 +60,7 @@ public override void OnInspectorGUI() GUILayout.Space(5); - if (GUILayout.Button("Test Grammar") || testValue == null) + if (GUILayout.Button("Test Grammar")|| testValue==null) { Grammar grammar = ((TraceryGrammar)target).Grammar; testValue = grammar.Flatten("#origin#"); diff --git a/Source/Unity/TraceryGrammar.cs b/Source/Unity/TraceryGrammar.cs index 2da46e2..6c73719 100644 --- a/Source/Unity/TraceryGrammar.cs +++ b/Source/Unity/TraceryGrammar.cs @@ -15,7 +15,7 @@ public Grammar Grammar { grammar.PushRules(s.key, s.rules.Split('\n')); } - return grammar; + return grammar; } }