From e633a43f2ebdb612dc3274c5cec2a027d8eec90b Mon Sep 17 00:00:00 2001 From: Nathan Braswell Date: Mon, 3 Jan 2022 02:17:52 -0500 Subject: [PATCH] Parsing strings, but naively without escapes yet --- partial_eval.csc | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/partial_eval.csc b/partial_eval.csc index daefb3f..0dd8800 100644 --- a/partial_eval.csc +++ b/partial_eval.csc @@ -2478,6 +2478,47 @@ (_if '$at_least1 (i32.ge_u (global.get '$phl) (i32.const 1)) (then + ; string + (_if '$is_open + (i32.eq (i32.load8_u (global.get '$phs)) (i32.const #x22)) + (then + (global.set '$phs (i32.add (global.get '$phs) (i32.const 1))) + (global.set '$phl (i32.sub (global.get '$phl) (i32.const 1))) + (local.set '$asiz (i32.const 0)) + (local.set '$bptr (global.get '$phs)) + (_loop '$il + (_if '$doesnt_have_next + (i32.eqz (global.get '$phl)) + (then + (local.set '$result (i64.const empty_parse_value)) + (br '$b1) + ) + ) + (_if '$is_end + (i32.eq (i32.load8_u (global.get '$phs)) (i32.const #x22)) + (then + (local.set '$aptr (call '$malloc (local.get '$asiz))) + (memory.copy (local.get '$aptr) + (local.get '$bptr) + (local.get '$asiz)) + (local.set '$result (i64.or (i64.or (i64.extend_i32_u (local.get '$aptr)) (i64.const #x3)) + (i64.shl (i64.extend_i32_u (local.get '$asiz)) (i64.const 32)))) + (global.set '$phs (i32.add (global.get '$phs) (i32.const 1))) + (global.set '$phl (i32.sub (global.get '$phl) (i32.const 1))) + (br '$b1) + ) + ) + (global.set '$phs (i32.add (global.get '$phs) (i32.const 1))) + (global.set '$phl (i32.sub (global.get '$phl) (i32.const 1))) + (local.set '$asiz (i32.add (local.get '$asiz) (i32.const 1))) + (br '$il) + ) + ) + ) + ; symbol + ; int + ; ' + ; []? (_if '$is_open (i32.eq (i32.load8_u (global.get '$phs)) (i32.const #x28)) (then @@ -3272,7 +3313,9 @@ ;(output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (written code) (read-string (cond written \" true\" true 3))))")))) ;(output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (written code) (read-string (cond written \" true \" true 3))))")))) ;(output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (written code) (read-string (cond written \" false\" true 3))))")))) - (output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (written code) (read-string (cond written \"(false (true () true) true)\" true 3))))")))) + ;(output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (written code) (read-string (cond written \"(false (true () true) true)\" true 3))))")))) + (output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (written code) (read-string (cond written \"(false \\\"some string\\\" true)\" true 3))))")))) + ;(output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (written code) (read-string (cond written \"(false \\\"some string true)\" true 3))))")))) ;(output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (& args) (slice args 1 -1)))")))) ;(output3 (compile (partial_eval (read-string "(array ((vau (x) x) write) 1 \"waa\" (vau (& args) (len args)))"))))