-
Notifications
You must be signed in to change notification settings - Fork 1
/
boot.poem
120 lines (104 loc) · 3.67 KB
/
boot.poem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
include "./debug.wast"
include "./api.poem"
var meaning_of_life = 42.5
var meaning_of_life2 = false
var name = '"Hello \"world"! 🤖'
var my_pet =
:name = "Fido"
:species = "dog"
:age = 3
:male = true
:nutered = false
:mother =
:name = "Rita"
:age = 10
:male = false
:father = null
var friends =
"Alice"
'Bob'
'Charlie'
"Dennis"
func sum a b
var tableindex = #init
return a + b + meaning_of_life
export "init" init
test_json
~ make_a_cup_of tea
func test_json
var val = "Små søde\njordbær!🍓"
log val
log json_encode val
val = "\"\\\/\b\f\n\t\u0000"
log val
log json_encode val
log json_encode friends
log json_encode my_pet
log "" + json_decode "42"
log "" + json_decode "-42.50E-1"
log json_decode '"Sm\\u00e5 s\\u00f8de\\njordb\\u00e6r!\\ud83c\\udf53"'
log json_encode (json_decode (json_encode friends))
log json_encode (json_decode "{\"form\":96,\"params\":[127,127],\"returns\":[127]}")
log json_encode json_decode json_encode json_decode "{\n \"pi\": 3.141592653589793,\n \"name\": \"poetry-compiler\",\n \"version\": \"0.34.0\",\n \"description\": \"Poetic programming language that compiles to webassembly\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"node cli.js boot.poem -t boot.wast -b boot.wasm --debug boot.debug.json\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"bin\": {\n \"poetry\": \".\/cli.js\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https:\/\/github.com\/FantasyInternet\/poetry.git\"\n },\n \"keywords\": [\n \"wasm\",\n \"webassembly\",\n \"compiler\",\n \"programming\",\n \"language\",\n \"poetry\"\n ],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"bugs\": {\n \"url\": \"https:\/\/github.com\/FantasyInternet\/poetry\/issues\"\n },\n \"homepage\": \"https:\/\/github.com\/FantasyInternet\/poetry#readme\",\n \"dependencies\": {\n \"commander\": \"^2.17.1\",\n \"wabt\": \"^1.0.0\"\n }\n}"
func test_unicode
var danish = "æøå$¢€𐍈💩"
for i in range 0 (string_length danish)
log (char (char_code danish i))
func test_if
if false
log "one"
elsif false
log "two"
elsif false
log "three"
else
log "four"
func test_search
log "Charlie is my " + (array_search friends "Charlie") + "th friend!"
var friend = "Chøarlie"
var sub = "lie"
log friend + " has '"+sub+"' at " + (string_search friend sub 0 )
func test_split
var list = ",one,two,,three,four,"
var arr = string_split list ","
for item in arr
log item
log array_join arr ";"
arr = array
log array_join arr ";"
array_push arr
log array_join arr ";"
array_push arr
log array_join arr ";"
func test_tableindex
var tableindex = #sum
log_number #tableindex tableindex meaning_of_life2
log_number echo sum tableindex meaning_of_life2
func test_whatever
log name + " " + -32.00125
var friend = friends[1 + 1]
log friend
var i = 10
if i > 0
log "yay!"
else
log "nay..."
log "Greetings to all of my friends!"
for frend in friends
log "Hello " + frend + "! How are you!"
func test_shifting
log (array_unshift (friends) (array_pop (friends)))
log (array_unshift friends (array_pop friends))
log array_unshift friends string_upper array_pop friends
log array_unshift friends `to` array_pop friends
log array_unshift friends string_lower array_pop friends
log array_unshift friends array_pop friends
log array_unshift friends array_pop friends
log array_unshift friends array_pop friends
func introduce
for friend1 in friends
for friend2 in friends
log friend1+", meet "+friend2+"!"
export "echo" echo num
~ log_number num
return num