diff --git a/Readme.md b/Readme.md index e649e8f..1a24d75 100755 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,8 @@ # Meow lang -Meow lang is a programming language that compiles to *cat*, another language that is hard to read but easy to execute. Meow's syntax is easier to read than cat, but meow and cat are equivalent. +Meow lang is a programming language that compiles to *catlet*, another language that is hard to read but easy to execute. Meow's syntax is easier to read than catlet, but meow and catlet are equivalent. + +(It's called *catlet* because the only available two keywords are `cat` and `let`) Its main design purpose is to do experiments with "string substitution". @@ -21,7 +23,7 @@ The only available data type is **String**. (However, you can encode other data cargo run repl -# Now you can use the REPL to evaluate (cat) expressions +# Now you can use the REPL to evaluate (catlet) expressions ``` Example: @@ -40,7 +42,8 @@ hello world - [Syntax](./docs/Syntax.md) - [Encoding](./docs/Encoding.md) - [Double Substitution Lemma](./docs/DSL.md) +- [i Expressions](./docs/i-expr.md) ## Examples -See [syn.meow](./examples/syn.meow), which has compiling result [syn.cat](./examples/syn.cat). +See [syn.meow](./examples/syn.meow), which has compiled result [syn.cat](./examples/syn.cat). diff --git a/examples/syn.meow b/examples/syn.meow index 8dd2b44..341aab2 100644 --- a/examples/syn.meow +++ b/examples/syn.meow @@ -133,15 +133,15 @@ ten() { } revdigit(x) { - "S0"="1"; - "SS0"="2"; - "SSS0"="3"; - "SSSS0"="4"; - "SSSSS0"="5"; - "SSSSSS0"="6"; - "SSSSSSS0"="7"; - "SSSSSSSS0"="8"; - "SSSSSSSSS0"="9"; + "S0" = "1"; + "SS0" = "2"; + "SSS0" = "3"; + "SSSS0" = "4"; + "SSSSS0" = "5"; + "SSSSSS0" = "6"; + "SSSSSSS0" = "7"; + "SSSSSSSS0" = "8"; + "SSSSSSSSS0" = "9"; x } @@ -168,14 +168,18 @@ num(x) { var hd = head(x); var hdnum = revdigit(hd); var remain = { - "$"+ hdnum = ""; - "$"+x + "$" + hdnum = ""; + "$" + x }; - !(if(eq(len(x), "S0"), spack(digit(x)), `add mul "`+ hd + `" exp ten "`+nl+`" `+`num "` + remain + `"`)) + !(if( + eq(len(x), "S0"), + spack(digit(x)), + `add mul "` + hd + `" exp ten "` + nl + `" ` + `num "` + remain + `"` + )) } spack(x) { - `"`+x+`"` + `"` + x + `"` } leq(x,y) { @@ -191,7 +195,11 @@ show(x) { "SSSSSSSSSS" = "S"; sub(x,la) }; - !(if(leq(len(x), digit("9")), spack(revdigit(x)) , `cat show "` + rem + `" revdigit "` + la + `"`)) + !(if( + leq(len(x), digit("9")), + spack(revdigit(x)), + `cat show "` + rem + `" revdigit "` + la + `"` + )) } fib(x) {