From 3bc6204429d0a874f478a66867bb134deba36d87 Mon Sep 17 00:00:00 2001 From: "Chen, Chien-ting" Date: Mon, 14 Jun 2021 23:40:43 +0800 Subject: [PATCH] add syntax docu and docu_aux --- src/Interpreter/__init__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Interpreter/__init__.py b/src/Interpreter/__init__.py index 4d96652..5e47101 100644 --- a/src/Interpreter/__init__.py +++ b/src/Interpreter/__init__.py @@ -283,6 +283,14 @@ class Intepreter: (sexp[0]["line"], sexp[0]["col"])) else: return str(self.interprete_aux(sexp[1])) + + elif sexp[0]["token"] == "str-append": + if len(sexp) != 3: + raise Exception("Ln %d, Col %d: the argument number of str should be 2" % + (sexp[0]["line"], sexp[0]["col"])) + else: + return sexp[1] + sexp[2] + elif sexp[0]["token"] == "print": if len(sexp) != 2: raise Exception("Ln %d, Col %d: the argument number of print should be 1" % @@ -459,6 +467,17 @@ text = ''' """text = '''[[[ 123 1.23 abc "\\123\\\"貓貓貓"] 我是貓,喵\[喵\]貓\%。喵喵%喵 ]]''' + +% TODO +[def-syntax docu + [[_ x] [sile[docu_aux x]]] + [[_ x y...] [sile[docu_aux x y...]]]] + +[def-syntax docu_aux + [[_ x] [str x]] + [[_ [x...] [str [x...]]]] + [[_ x y...] [str-append[docu_aux x] [docu y...]]]]] + """ interp = Intepreter()