Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
linsyking committed Apr 4, 2023
1 parent d0a92b2 commit 9404fbe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
9 changes: 6 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -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".

Expand All @@ -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:
Expand All @@ -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).
36 changes: 22 additions & 14 deletions examples/syn.meow
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 9404fbe

Please sign in to comment.