-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
333 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,88 @@ | ||
# meow~ | ||
# Meow lang | ||
|
||
Another style: | ||
```meow | ||
true() { "T" } | ||
Meow lang is a programming language that is designed to **not** be easy to learn and use. | ||
|
||
Its mean design purpose is to do experiments with "string replacement". | ||
|
||
## How to run | ||
|
||
```bash | ||
cargo run <your meow file path> | ||
|
||
# Now you can use the REPL to evaluate expressions | ||
``` | ||
|
||
Run the example code: | ||
|
||
``` | ||
no error found. | ||
> true() | ||
T | ||
> false() | ||
F | ||
> {var x = zero();succ(x)} | ||
S0 | ||
> dr("a","aba","aba") | ||
aba | ||
> m() | ||
abcd | ||
``` | ||
|
||
## Examples | ||
|
||
```meow | ||
true() {"T"} | ||
false() {"F"} | ||
zero() {"0"} | ||
succ(x) {"S" + x} | ||
succ(x) {"S"+x} | ||
if(c,y,x) { | ||
var custom = y + "1"; | ||
"0" = x; | ||
y + "1" = y; | ||
true() = custom; | ||
false() = "0"; | ||
c | ||
pred(x) { | ||
"S0" = "0"; | ||
x | ||
} | ||
succ2(x) { | ||
succ(succ(x)) | ||
dr(x,y,z) { | ||
y = x; | ||
x = y; | ||
z | ||
} | ||
rep_test() { | ||
"dd" = "d"; | ||
var x = {"dddd"}; | ||
var y = "dddd"; | ||
"x=" + x + ",y=" + y | ||
} | ||
encode(s) { | ||
var rep = { | ||
"\" = "\\"; | ||
"$" = "\$"; | ||
"^" = "\^"; | ||
s | ||
}; | ||
"_^"+ rep +"_$" | ||
} | ||
decode(s) { | ||
var rep = { | ||
"_^" = ""; | ||
"_$" = ""; | ||
s | ||
}; | ||
"\$" = "$"; | ||
"\^" = "^"; | ||
"\\" = "\"; | ||
rep | ||
} | ||
``` | ||
m(){ | ||
var s = "abcd"; | ||
var enc = encode(s); | ||
var dec = decode(enc); | ||
dec | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# String Operation | ||
|
||
Definition of replacement: | ||
|
||
$[a/b]c := \begin{cases} | ||
xa[a/b]y, \exist x, y,(b\not\subset x)\land (c=xby) \\ | ||
c, \text{otherwise} | ||
\end{cases}$ | ||
|
||
Double Replacement Lemma: | ||
|
||
$[x/y]([y/x]y)=\begin{cases} | ||
y, x\subset y\\ | ||
x, \text{otherwise} | ||
\end{cases}$ | ||
|
||
Similar result: | ||
$[x/yy]([yy/x]y)=y$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,54 @@ | ||
hh() { "dd" } | ||
sdf(hhs, fff) { | ||
"fd" = hhg("ss"); | ||
var ldk = { | ||
var s = ("ff" + hhs + "d"); | ||
"hhh" | ||
true() {"T"} | ||
|
||
false() {"F"} | ||
|
||
zero() {"0"} | ||
|
||
succ(x) {"S"+x} | ||
|
||
pred(x) { | ||
"S0" = "0"; | ||
x | ||
} | ||
|
||
dr(x,y,z) { | ||
y = x; | ||
x = y; | ||
z | ||
} | ||
|
||
rep_test() { | ||
"dd" = "d"; | ||
var x = {"dddd"}; | ||
var y = "dddd"; | ||
"x=" + x + ",y=" + y | ||
} | ||
|
||
encode(s) { | ||
var rep = { | ||
"\" = "\\"; | ||
"$" = "\$"; | ||
"^" = "\^"; | ||
s | ||
}; | ||
"ffs" | ||
"_^"+ rep +"_$" | ||
} | ||
|
||
decode(s) { | ||
var rep = { | ||
"_^" = ""; | ||
"_$" = ""; | ||
s | ||
}; | ||
"\$" = "$"; | ||
"\^" = "^"; | ||
"\\" = "\"; | ||
rep | ||
} | ||
|
||
m(){ | ||
var s = "abcd"; | ||
var enc = encode(s); | ||
var dec = decode(enc); | ||
dec | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.