diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-01-10 16:30:34 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-01-10 16:30:34 +0800 |
| commit | 52a6536103f46c26a3ba9b149b0fe7b40d524d8c (patch) | |
| tree | 67e4759f8e1ea922079d0e162d84ecba5e558261 /spec/inputs/syntax.moon | |
| parent | 975167856ed0b11c2ede03c6eb750ca4e4a6a7fc (diff) | |
| download | yuescript-52a6536103f46c26a3ba9b149b0fe7b40d524d8c.tar.gz yuescript-52a6536103f46c26a3ba9b149b0fe7b40d524d8c.tar.bz2 yuescript-52a6536103f46c26a3ba9b149b0fe7b40d524d8c.zip | |
update.
Diffstat (limited to '')
| -rw-r--r-- | spec/inputs/syntax.moon | 272 |
1 files changed, 272 insertions, 0 deletions
diff --git a/spec/inputs/syntax.moon b/spec/inputs/syntax.moon new file mode 100644 index 0000000..854f629 --- /dev/null +++ b/spec/inputs/syntax.moon | |||
| @@ -0,0 +1,272 @@ | |||
| 1 | #!/this/is/ignored | ||
| 2 | |||
| 3 | a = 1 + 2* 3 / 6 | ||
| 4 | |||
| 5 | a, bunch, go, here = another, world | ||
| 6 | |||
| 7 | func arg1, arg2, another, arg3 | ||
| 8 | |||
| 9 | here, we = () ->, yeah | ||
| 10 | the, different = () -> approach; yeah | ||
| 11 | |||
| 12 | dad() | ||
| 13 | dad(lord) | ||
| 14 | hello(one,two)() | ||
| 15 | (5 + 5)(world) | ||
| 16 | |||
| 17 | fun(a)(b) | ||
| 18 | |||
| 19 | fun(a) b | ||
| 20 | |||
| 21 | fun(a) b, bad hello | ||
| 22 | |||
| 23 | hello world what are you doing here | ||
| 24 | |||
| 25 | |||
| 26 | what(the)[3243] world, yeck heck | ||
| 27 | |||
| 28 | hairy[hands][are](gross) okay okay[world] | ||
| 29 | |||
| 30 | (get[something] + 5)[years] | ||
| 31 | |||
| 32 | i,x = 200, 300 | ||
| 33 | |||
| 34 | yeah = (1 + 5) * 3 | ||
| 35 | yeah = ((1+5)*3)/2 | ||
| 36 | yeah = ((1+5)*3)/2 + i % 100 | ||
| 37 | |||
| 38 | whoa = (1+2) * (3+4) * (4+5) | ||
| 39 | |||
| 40 | -> | ||
| 41 | if something | ||
| 42 | return 1,2,4 | ||
| 43 | |||
| 44 | print "hello" | ||
| 45 | |||
| 46 | -> | ||
| 47 | if hello | ||
| 48 | "heloo", "world" | ||
| 49 | else | ||
| 50 | no, way | ||
| 51 | |||
| 52 | |||
| 53 | -> 1,2,34 | ||
| 54 | |||
| 55 | return 5 + () -> 4 + 2 | ||
| 56 | |||
| 57 | return 5 + (() -> 4) + 2 | ||
| 58 | |||
| 59 | print 5 + () -> | ||
| 60 | 34 | ||
| 61 | good nads | ||
| 62 | |||
| 63 | |||
| 64 | something 'else', "ya" | ||
| 65 | |||
| 66 | something'else' | ||
| 67 | something"else" | ||
| 68 | |||
| 69 | something[[hey]] * 2 | ||
| 70 | something[======[hey]======] * 2 | ||
| 71 | |||
| 72 | |||
| 73 | something'else', 2 | ||
| 74 | something"else", 2 | ||
| 75 | something[[else]], 2 | ||
| 76 | |||
| 77 | something 'else', 2 | ||
| 78 | something "else", 2 | ||
| 79 | something [[else]], 2 | ||
| 80 | |||
| 81 | here(we)"go"[12123] | ||
| 82 | |||
| 83 | -- this runs | ||
| 84 | something = | ||
| 85 | test: 12323 | ||
| 86 | what: -> print "hello world" | ||
| 87 | |||
| 88 | print something.test | ||
| 89 | |||
| 90 | frick = hello: "world" | ||
| 91 | |||
| 92 | argon = | ||
| 93 | num: 100 | ||
| 94 | world: (self) -> | ||
| 95 | print self.num | ||
| 96 | return { | ||
| 97 | something: -> print "hi from something" | ||
| 98 | } | ||
| 99 | somethin: (self, str) -> | ||
| 100 | print "string is", str | ||
| 101 | return world: (a,b) -> print "sum", a + b | ||
| 102 | |||
| 103 | something.what() | ||
| 104 | argon\world().something() | ||
| 105 | |||
| 106 | argon\somethin"200".world(1,2) | ||
| 107 | |||
| 108 | x = -434 | ||
| 109 | |||
| 110 | x = -hello world one two | ||
| 111 | |||
| 112 | hi = -"herfef" | ||
| 113 | |||
| 114 | x = -[x for x in x] | ||
| 115 | |||
| 116 | print "hello" if cool | ||
| 117 | print "hello" unless cool | ||
| 118 | print "hello" unless 1212 and 3434 -- hello | ||
| 119 | print "hello" for i=1,10 | ||
| 120 | |||
| 121 | print "nutjob" | ||
| 122 | |||
| 123 | if hello then 343 | ||
| 124 | |||
| 125 | print "what" if cool else whack | ||
| 126 | |||
| 127 | arg = {...} | ||
| 128 | |||
| 129 | x = (...) -> | ||
| 130 | dump {...} | ||
| 131 | |||
| 132 | |||
| 133 | x = not true | ||
| 134 | |||
| 135 | y = not(5+5) | ||
| 136 | |||
| 137 | |||
| 138 | y = #"hello" | ||
| 139 | |||
| 140 | x = #{#{},#{1},#{1,2}} | ||
| 141 | |||
| 142 | hello, world | ||
| 143 | |||
| 144 | something\hello(what) a,b | ||
| 145 | something\hello what | ||
| 146 | something.hello\world a,b | ||
| 147 | something.hello\world(1,2,3) a,b | ||
| 148 | |||
| 149 | |||
| 150 | x = 1232 | ||
| 151 | x += 10 + 3 | ||
| 152 | j -= "hello" | ||
| 153 | y *= 2 | ||
| 154 | y /= 100 | ||
| 155 | m %= 2 | ||
| 156 | hello ..= "world" | ||
| 157 | |||
| 158 | @@something += 10 | ||
| 159 | @something += 10 | ||
| 160 | |||
| 161 | a["hello"] += 10 | ||
| 162 | a["hello#{tostring ff}"] += 10 | ||
| 163 | a[four].x += 10 | ||
| 164 | |||
| 165 | x = 0 | ||
| 166 | (if ntype(v) == "fndef" then x += 1) for v in *values | ||
| 167 | |||
| 168 | |||
| 169 | hello = | ||
| 170 | something: world | ||
| 171 | if: "hello" | ||
| 172 | else: 3434 | ||
| 173 | function: "okay" | ||
| 174 | good: 230203 | ||
| 175 | |||
| 176 | |||
| 177 | div class: "cool" | ||
| 178 | |||
| 179 | 5 + what wack | ||
| 180 | what whack + 5 | ||
| 181 | |||
| 182 | 5 - what wack | ||
| 183 | what whack - 5 | ||
| 184 | |||
| 185 | x = hello - world - something | ||
| 186 | |||
| 187 | ((something = with what | ||
| 188 | \cool 100) -> | ||
| 189 | print something)! | ||
| 190 | |||
| 191 | if something | ||
| 192 | 03589 | ||
| 193 | |||
| 194 | -- okay what about this | ||
| 195 | |||
| 196 | else | ||
| 197 | 3434 | ||
| 198 | |||
| 199 | |||
| 200 | if something | ||
| 201 | yeah | ||
| 202 | |||
| 203 | |||
| 204 | elseif "ymmm" | ||
| 205 | |||
| 206 | print "cool" | ||
| 207 | |||
| 208 | else | ||
| 209 | |||
| 210 | okay | ||
| 211 | |||
| 212 | |||
| 213 | -- test names containing keywords | ||
| 214 | x = notsomething | ||
| 215 | y = ifsomething | ||
| 216 | z = x and b | ||
| 217 | z = x andb | ||
| 218 | |||
| 219 | |||
| 220 | -- undelimited tables | ||
| 221 | |||
| 222 | while 10 > something | ||
| 223 | something: "world" | ||
| 224 | print "yeah" | ||
| 225 | |||
| 226 | x = | ||
| 227 | okay: sure | ||
| 228 | |||
| 229 | yeah | ||
| 230 | okay: man | ||
| 231 | sure: sir | ||
| 232 | |||
| 233 | hello "no comma" | ||
| 234 | yeah: dada | ||
| 235 | another: world | ||
| 236 | |||
| 237 | hello "comma", | ||
| 238 | something: hello_world | ||
| 239 | frick: you | ||
| 240 | |||
| 241 | -- creates two tables | ||
| 242 | another hello, one, | ||
| 243 | two, three, four, yeah: man | ||
| 244 | okay: yeah | ||
| 245 | |||
| 246 | -- | ||
| 247 | a += 3 - 5 | ||
| 248 | a *= 3 + 5 | ||
| 249 | a *= 3 | ||
| 250 | a >>= 3 | ||
| 251 | a <<= 3 | ||
| 252 | a /= func "cool" | ||
| 253 | |||
| 254 | --- | ||
| 255 | |||
| 256 | x.then = "hello" | ||
| 257 | x.while.true = "hello" | ||
| 258 | |||
| 259 | -- | ||
| 260 | |||
| 261 | x or= "hello" | ||
| 262 | x and= "hello" | ||
| 263 | |||
| 264 | -- | ||
| 265 | |||
| 266 | z = a-b | ||
| 267 | z = a -b | ||
| 268 | z = a - b | ||
| 269 | z = a- b | ||
| 270 | |||
| 271 | |||
| 272 | -- cooool | ||
