From 38aad3dcda01fc5ed82556dbfdf4cfc30ff479d9 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Wed, 14 Aug 2019 18:28:10 +0200
Subject: Began syntactical analysis

---
 src/Lexical.kt    | 16 +---------------
 src/Syntax.kt     |  7 +++++++
 src/Testing.kt    |  7 +------
 src/TokenTypes.kt | 14 ++++++++++++++
 4 files changed, 23 insertions(+), 21 deletions(-)
 create mode 100644 src/Syntax.kt
 create mode 100644 src/TokenTypes.kt

diff --git a/src/Lexical.kt b/src/Lexical.kt
index 1655805..df60a8e 100644
--- a/src/Lexical.kt
+++ b/src/Lexical.kt
@@ -13,6 +13,7 @@ class Lexical {
                 if (buffer == "\"") stringMode = true
                 buffer = ""
             }
+            if (tokenType == TokenType.Empty) buffer = ""
         }
         return tokens
     }
@@ -65,18 +66,3 @@ class Lexical {
     private val brackets = listOf("(", ")", "[", "]", "{", "}") // TODO: Use brackets for functions
     private val classifier = listOf("\"")  // TODO: Add char mode e.g 'a'
 }
-
-enum class TokenType {
-    Keyword,
-    Assignment,
-    Arithmetic,
-    Comparison,
-    Logical,
-    Identifier,
-    Constant,
-    Punctuation,
-    Bracket,
-    Classifier,
-    Empty,
-    Skip
-}
\ No newline at end of file
diff --git a/src/Syntax.kt b/src/Syntax.kt
new file mode 100644
index 0000000..7d7ab9d
--- /dev/null
+++ b/src/Syntax.kt
@@ -0,0 +1,7 @@
+class Syntax {
+    fun check(tokens: MutableList<Pair<String, TokenType>>) {
+        for (token in tokens) {
+            print(token)
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Testing.kt b/src/Testing.kt
index 4e4ec0d..d1e6b17 100644
--- a/src/Testing.kt
+++ b/src/Testing.kt
@@ -2,12 +2,7 @@ class Testing {
     init {
         val source = Loader("/home/melvin/coding/run/example.run").load()
         val tokens = Lexical().analyze(source)
-        for (token in tokens) {
-            print(token.first)
-            print(" => ")
-            print(token.second)
-            print("\n")
-        }
+        Syntax().check(tokens)
         print(source)
     }
 }
\ No newline at end of file
diff --git a/src/TokenTypes.kt b/src/TokenTypes.kt
new file mode 100644
index 0000000..9e15b5a
--- /dev/null
+++ b/src/TokenTypes.kt
@@ -0,0 +1,14 @@
+enum class TokenType {
+    Keyword,
+    Assignment,
+    Arithmetic,
+    Comparison,
+    Logical,
+    Identifier,
+    Constant,
+    Punctuation,
+    Bracket,
+    Classifier,
+    Empty,
+    Skip
+}
\ No newline at end of file
-- 
cgit v1.2.3