diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-21 02:33:04 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-21 02:33:04 -0700 |
| commit | 5f2db8da0e99fca282265b232330f3f432b94373 (patch) | |
| tree | 5c27a1f958b55a15b0e35139165c885574d4fa3a /examples | |
| parent | 371548150618d5b3501f388972077b5d035f7d8a (diff) | |
Everything fixed up and some reduced lua codespew too!
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/parser_tests.nom | 7 | ||||
| -rw-r--r-- | examples/sample_code.nom | 6 | ||||
| -rw-r--r-- | examples/sample_game.nom | 3 | ||||
| -rw-r--r-- | examples/tutorial.nom | 9 |
4 files changed, 14 insertions, 11 deletions
diff --git a/examples/parser_tests.nom b/examples/parser_tests.nom index b1eb23b..b91266e 100644 --- a/examples/parser_tests.nom +++ b/examples/parser_tests.nom @@ -1,4 +1,5 @@ require "lib/core.nom" +require "lib/testing.nom" test: say "foo" ..yields ".." @@ -148,12 +149,12 @@ test: z ..yields ".." |Call [if % % else %]: - | Var[x] + | Var["x"] | Thunk: | Call [x]! | Thunk: | Call [if % % else %]: - | Var[y] + | Var["y"] | Thunk: | Call [y]! | Thunk: @@ -169,6 +170,6 @@ test: %Brian's hat ..yields ".." |Call [% 's hat]: - | Var[Brian] + | Var["Brian"] say "All tests passed!" diff --git a/examples/sample_code.nom b/examples/sample_code.nom index e2b3a62..fe73ec7 100644 --- a/examples/sample_code.nom +++ b/examples/sample_code.nom @@ -78,7 +78,7 @@ if 1: yes if 1 (:yes) else (:no) -say (do: return: 5) +say (do: return 5) # Some variables rule [do %one also %two] =: @@ -88,7 +88,7 @@ rule [do %one also %two] =: do: say "one liner" ..also: say "another one liner" -say (do: return: "wow") +say (do: return "wow") say (1 + (-(2 * 3))) @@ -146,7 +146,7 @@ rule [dumsum %nums] =: %sum =: 0 for %n in %nums: %sum +=: %n - return: %sum + return %sum say (dumsum [1,2,3]) diff --git a/examples/sample_game.nom b/examples/sample_game.nom index 44b9d35..1f526e3 100644 --- a/examples/sample_game.nom +++ b/examples/sample_game.nom @@ -1,4 +1,5 @@ require "lib/core.nom" +require "lib/permissions.nom" require "lib/secrets.nom" require "lib/plurals.nom" @@ -101,8 +102,6 @@ with secrets: say ".." |Proposal: |\%src\ - say "foo" - macro block [propose %action] =: %source =: source code from tree %action diff --git a/examples/tutorial.nom b/examples/tutorial.nom index 306a0af..8739348 100644 --- a/examples/tutorial.nom +++ b/examples/tutorial.nom @@ -234,6 +234,7 @@ sing 9 bottles of beer say (5 + (4 * (- (1 + (6 + 2))))) # For convenience, +,*,"and", and "or" have been hand defined to work with up to 4 operands: 1 + 2 + 3 + 4 +say "Done with math." 1 * 2 * 3 * 4 1 and 2 and 3 and 4 1 or 2 or 3 or 4 @@ -245,6 +246,8 @@ any of [0,0,0,0,1,0,0] # And 3-operand chained inequality comparisons have been defined: 1 < 2 <= 3 +say "Done with math." + # Macros: # The "lua block %" and "lua expr %" macros can be used to write raw lua code: @@ -264,8 +267,8 @@ say ".."|The square root of 2 is \square root of 2\ # Macros can be defined as functions that take unprocessed syntax trees and return lua code # "macro block %" is for defining macros that produce blocks of code, not values macro block [unless %condition %body] =: ".." - |if not (\%condition as lua expr\) then - | \(lua expr "vars.body.value") as lua block\ + |if not (\%condition as lua\) then + | \(lua expr "vars.body.value") as lua\ |end unless (1 > 10): @@ -274,6 +277,6 @@ unless (1 > 10): # and "macro %" is for defining macros that produce an expression macro [%value as a boolean] =: ".." - |(not not (\%value as lua expr\)) + |(not not (\%value as lua\)) macro [yep] =: "true" |
