diff options
Diffstat (limited to 'examples/sample_code.nom')
| -rw-r--r-- | examples/sample_code.nom | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/examples/sample_code.nom b/examples/sample_code.nom deleted file mode 100644 index 08f2af5..0000000 --- a/examples/sample_code.nom +++ /dev/null @@ -1,150 +0,0 @@ -# This is just a comment -#.. Block comments - start with a #.. and - continue until dedent - -require "lib/core.nom" - -say "foo" - -say (-4 + (1.5 - .25)) - -#.. "rule" is just a macro that takes a function call spec and a block of code to run, - and stores the function definition -rule [fart] =: say "poot" - -# multi-line strings: -say ".." - | Once upon a time - |there was a very - - - |long string - | - | with - | rather - | silly # fake comments and - # Real comments look like this - | indentation - - | and "quotes" - |.." (even fakeouts like that) " - |(done) - | - |^and trailing spaces - | - -say "Strings have interpolation: \(1 + 2) <- like that" - -rule [doublefart] =: # this farts twice - say "poot" - say "poot" - -doublefart - -rule [subex work] =: "subexpressions work" - -say (subex work) - -say (..) - subex work - -say ["lists", "work"] - -say [] - -say [..] - 1, 2 - 3 - -rule [say both %1 and %2] =: - say %1 - say %2 - -say both [..] - 1,2 -..and [..] - 3,4 - - -rule [three] =: 3 -say both -.."a list:" -..and [..] - 1,2,three,4 - -if 1: yes -..else: no - -if 1 {yes} else {no} - -say (do {return 5}) - -# Some variables -rule [do %one also %two] =: - do %one - do %two - -do: say "one liner" -..also: say "another one liner" - -say (do {return "wow"}) - -say (1 + (-(2 * 3))) - -say (..) - 2 + (..) - 3 * 4 - -when: - * (%x == 1): - say "one" - * (%x == 2): - say "two" - * %x: - say "nonzero" - * else: - say "???" - -when %x == ?: - * 1: - say "one" - * 2: - say "two" - * else: - say "???" - - -if %x: - say "one" -..else: - if %y: - say "two" - ..else: - say "three" - - -say ".." - |this is a longstring - | - | with multiple lines - | and an interpolated expression: \2 + 5\ - -rule [%n bottles] =: - lua do> ".." - |print("running raw lua code...") - |for i=\(%n),1,-1 do - | print(tostring(i).." bottles of beer on the wall. Take one down, pass it around,") - |end - |print("no more bottles of beer on the wall.") - nil -9 bottles - -rule [dumsum %nums] =: - %sum = 0 - for %n in %nums: - %sum += %n - return %sum - -say (dumsum [1,2,3]) - |
