diff --git a/demo/example.dee b/demo/example.dee index 45a58f7..db96e7d 100644 --- a/demo/example.dee +++ b/demo/example.dee @@ -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("Hello world!") ## Hello world -name <- read() -print("Hi there $name") ## Hi there - have <- 10 want <- 11 need <- have - want ## This is subtraction 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) ## (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() ## Hi from inside a function @@ -31,8 +18,8 @@ duck <- { eats? <- food -> food = "bread" } ## Objects created on the fly -print duck.eats?("bread") ## true -print duck.eats?("corn") ## false +print(duck.eats?("bread")) ## true +print(duck.eats?("corn")) ## false cow <- { talk <- print("Moo") @@ -43,15 +30,15 @@ human <- { eats? <- _ -> true } -print cow.eats?("grass") ## true -print cow.eats?("corn") ## true +print(cow.eats?("grass")) ## true +print(cow.eats?("corn")) ## true talk-or-pass-wind <- character -> - if character has talk then + if character has talk character.talk() else print("*Fart*") talk-or-pass-wind(duck) ## "Quack" talk-or-pass-wind(cow) ## "Moo" -talk-or-pass-wind(human) ## "*Fart*" \ No newline at end of file +talk-or-pass-wind(human) ## "*Fart*"