Remove no longer desired features from example
This commit is contained in:
parent
c29d463adf
commit
1e2c107c1b
@ -1,24 +1,11 @@
|
|||||||
## By the end of the book I want to have an interpreter
|
|
||||||
## for this little language, maybe a compiler too
|
|
||||||
|
|
||||||
print(1 + 1) ## 2
|
print(1 + 1) ## 2
|
||||||
print("Hello world!") ## Hello world
|
print("Hello world!") ## Hello world
|
||||||
|
|
||||||
name <- read()
|
|
||||||
print("Hi there $name") ## Hi there <name>
|
|
||||||
|
|
||||||
have <- 10
|
have <- 10
|
||||||
want <- 11
|
want <- 11
|
||||||
need <- have - want ## This is subtraction
|
need <- have - want ## This is subtraction
|
||||||
have-want <- 1 ## This is a variable named "have-want"
|
have-want <- 1 ## This is a variable named "have-want"
|
||||||
|
|
||||||
print(HaVe-WAnt) ## 1 (case doesn't matter)
|
|
||||||
%%option meaningful-casing
|
|
||||||
Apples <- 1
|
|
||||||
print(apples) ## <undef> (or maybe it does)
|
|
||||||
|
|
||||||
print("one fish"); print("two fish") ## Two statements on the same line
|
|
||||||
|
|
||||||
say-hi <- -> print("Hi from inside a function")
|
say-hi <- -> print("Hi from inside a function")
|
||||||
say-hi() ## Hi from inside a function
|
say-hi() ## Hi from inside a function
|
||||||
|
|
||||||
@ -31,8 +18,8 @@ duck <- {
|
|||||||
eats? <- food -> food = "bread"
|
eats? <- food -> food = "bread"
|
||||||
} ## Objects created on the fly
|
} ## Objects created on the fly
|
||||||
|
|
||||||
print duck.eats?("bread") ## true
|
print(duck.eats?("bread")) ## true
|
||||||
print duck.eats?("corn") ## false
|
print(duck.eats?("corn")) ## false
|
||||||
|
|
||||||
cow <- {
|
cow <- {
|
||||||
talk <- print("Moo")
|
talk <- print("Moo")
|
||||||
@ -43,11 +30,11 @@ human <- {
|
|||||||
eats? <- _ -> true
|
eats? <- _ -> true
|
||||||
}
|
}
|
||||||
|
|
||||||
print cow.eats?("grass") ## true
|
print(cow.eats?("grass")) ## true
|
||||||
print cow.eats?("corn") ## true
|
print(cow.eats?("corn")) ## true
|
||||||
|
|
||||||
talk-or-pass-wind <- character ->
|
talk-or-pass-wind <- character ->
|
||||||
if character has talk then
|
if character has talk
|
||||||
character.talk()
|
character.talk()
|
||||||
else
|
else
|
||||||
print("*Fart*")
|
print("*Fart*")
|
||||||
|
Loading…
Reference in New Issue
Block a user