The version number has been incremented. Variables can now be matched on explicitly.
authorimode <immediate.mode@gmail.com>
Thu, 15 Nov 2018 18:15:55 +0000 (10:15 -0800)
committerimode <immediate.mode@gmail.com>
Thu, 15 Nov 2018 18:15:55 +0000 (10:15 -0800)
modal.py

index f802cc6..c6e3fee 100644 (file)
--- a/modal.py
+++ b/modal.py
@@ -220,7 +220,7 @@ def literal(string, index=0):
         index = index + 1;
     return (token, index);
 
-def parse(string, index=0):
+def parse(string, index=0, query=False):
     results = [];
     while index != len(string):
         character = string[index];
@@ -233,6 +233,8 @@ def parse(string, index=0):
         elif character not in [' ', '\t', '\n', '\r']:
             token, index = literal(string, index);
             if character == '?':
+                if query:
+                    results.append(["LIT", "var"]);
                 results.append(["VAR", token]);
             elif number(token):
                 results.append(["LIT", "num"]);
@@ -308,7 +310,7 @@ def main():
             return;
         print("Initializating...");
         run(rules, parse(content));
-    print("Modal v0.01");
+    print("Modal v0.02");
     help();
     while True:
         input = prompt("::> ");
@@ -328,7 +330,7 @@ def main():
             break;
         else:
             print("Reducing...");
-            print(inspect(seek(run(rules, parse(input)), ["SRT"])));
+            print(inspect(seek(run(rules, parse(input, 0, True)), ["SRT"])));
     return;
 
 if __name__ == "__main__":