From 29795a0db4e1d180217123f81f14b69189b3c12c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 18 Jun 2021 21:41:17 -0700 Subject: start emitting indent tokens --- shell/parenthesize.mu | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 shell/parenthesize.mu (limited to 'shell/parenthesize.mu') diff --git a/shell/parenthesize.mu b/shell/parenthesize.mu new file mode 100644 index 00000000..67b50854 --- /dev/null +++ b/shell/parenthesize.mu @@ -0,0 +1,21 @@ +# TODO: not really implemented yet +fn parenthesize in: (addr stream token), out: (addr stream token), trace: (addr trace) { + trace-text trace, "parenthesize", "insert parens" + trace-lower trace + rewind-stream in + { + var done?/eax: boolean <- stream-empty? in + compare done?, 0/false + break-if-!= + # + var token-storage: token + var token/edx: (addr token) <- address token-storage + read-from-stream in, token + var is-indent?/eax: boolean <- indent-token? token + compare is-indent?, 0/false + loop-if-!= + write-to-stream out, token # shallow copy + loop + } + trace-higher trace +} -- cgit 1.4.1-2-gfad0