layo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +26 -0
- data/README.mkd +103 -0
- data/Rakefile +21 -0
- data/UnicodeData.txt +23697 -0
- data/bin/layo +22 -0
- data/layo.gemspec +23 -0
- data/lib/layo.rb +11 -0
- data/lib/layo/ast.rb +5 -0
- data/lib/layo/ast/block.rb +13 -0
- data/lib/layo/ast/expression.rb +14 -0
- data/lib/layo/ast/node.rb +6 -0
- data/lib/layo/ast/program.rb +9 -0
- data/lib/layo/ast/statement.rb +10 -0
- data/lib/layo/interpreter.rb +360 -0
- data/lib/layo/lexer.rb +162 -0
- data/lib/layo/parser.rb +371 -0
- data/lib/layo/peekable.rb +31 -0
- data/lib/layo/runtime_error.rb +9 -0
- data/lib/layo/syntax_error.rb +14 -0
- data/lib/layo/tokenizer.rb +119 -0
- data/lib/layo/unexpected_token_error.rb +13 -0
- data/lib/layo/unicode.rb +23614 -0
- data/lib/layo/unknown_token_error.rb +7 -0
- data/spec/interpreter_spec.rb +52 -0
- data/spec/lexer_spec.rb +176 -0
- data/spec/parser_spec.rb +373 -0
- data/spec/source/basic/comments.lol +16 -0
- data/spec/source/basic/comments.out +2 -0
- data/spec/source/basic/line-continuation.lol +8 -0
- data/spec/source/basic/line-continuation.out +2 -0
- data/spec/source/basic/line-endings.lol +5 -0
- data/spec/source/basic/line-endings.out +3 -0
- data/spec/source/basic/minimal.lol +2 -0
- data/spec/source/casting/boolean.lol +8 -0
- data/spec/source/casting/boolean.out +5 -0
- data/spec/source/casting/float.lol +10 -0
- data/spec/source/casting/float.out +5 -0
- data/spec/source/casting/int.lol +9 -0
- data/spec/source/casting/int.out +4 -0
- data/spec/source/casting/nil.lol +9 -0
- data/spec/source/casting/nil.out +4 -0
- data/spec/source/casting/string.lol +5 -0
- data/spec/source/casting/string.out +2 -0
- data/spec/source/expressions/boolean.lol +30 -0
- data/spec/source/expressions/boolean.out +17 -0
- data/spec/source/expressions/cast.lol +28 -0
- data/spec/source/expressions/cast.out +20 -0
- data/spec/source/expressions/function.lol +24 -0
- data/spec/source/expressions/function.out +4 -0
- data/spec/source/expressions/math.lol +9 -0
- data/spec/source/expressions/math.out +7 -0
- data/spec/source/expressions/string.lol +20 -0
- data/spec/source/expressions/string.out +7 -0
- data/spec/source/statements/assignment.lol +8 -0
- data/spec/source/statements/assignment.out +3 -0
- data/spec/source/statements/cast.lol +11 -0
- data/spec/source/statements/cast.out +3 -0
- data/spec/source/statements/declaration.lol +9 -0
- data/spec/source/statements/declaration.out +2 -0
- data/spec/source/statements/expression.lol +10 -0
- data/spec/source/statements/expression.out +2 -0
- data/spec/source/statements/if_then_else.lol +42 -0
- data/spec/source/statements/if_then_else.out +3 -0
- data/spec/source/statements/input.in +1 -0
- data/spec/source/statements/input.lol +4 -0
- data/spec/source/statements/input.out +1 -0
- data/spec/source/statements/loop.lol +50 -0
- data/spec/source/statements/loop.out +20 -0
- data/spec/source/statements/print.lol +7 -0
- data/spec/source/statements/print.out +2 -0
- data/spec/source/statements/switch.lol +95 -0
- data/spec/source/statements/switch.out +12 -0
- data/spec/tokenizer_spec.rb +105 -0
- metadata +135 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
BTW One line comment
|
2
|
+
HAI 1.2
|
3
|
+
BTW another comment
|
4
|
+
VISIBLE "comment test"
|
5
|
+
|
6
|
+
OBTW
|
7
|
+
it's multiline
|
8
|
+
comment. All BTW comments here are ignored
|
9
|
+
BTW TLDR, VISIBLE "multiline test"
|
10
|
+
KTHXBYE
|
11
|
+
|
12
|
+
OBTW
|
13
|
+
another multiline
|
14
|
+
comment
|
15
|
+
VISIBLE "commented out"
|
16
|
+
TLDR
|
@@ -0,0 +1,30 @@
|
|
1
|
+
HAI 1.2
|
2
|
+
|
3
|
+
BTW boolean logic
|
4
|
+
BTW and
|
5
|
+
VISIBLE BOTH OF WIN AN FAIL
|
6
|
+
VISIBLE BOTH OF 1 AN 5
|
7
|
+
BTW or
|
8
|
+
VISIBLE EITHER OF 0 AN 0
|
9
|
+
VISIBLE EITHER OF WIN AN 0
|
10
|
+
BTW xor
|
11
|
+
VISIBLE WON OF 1 AN 0
|
12
|
+
VISIBLE WON OF FAIL AN FAIL
|
13
|
+
BTW not
|
14
|
+
I HAS A var ITZ 5
|
15
|
+
VISIBLE NOT FAIL
|
16
|
+
VISIBLE NOT WIN
|
17
|
+
VISIBLE NOT var
|
18
|
+
BTW n-ary and
|
19
|
+
VISIBLE ALL OF WIN AN WIN AN WIN AN WIN MKAY
|
20
|
+
VISIBLE ALL OF FAIL AN WIN AN WIN
|
21
|
+
BTW n-ary or
|
22
|
+
VISIBLE ANY OF WIN AN FAIL MKAY
|
23
|
+
VISIBLE ANY OF FAIL AN FAIL AN FAIL
|
24
|
+
|
25
|
+
BTW comparison
|
26
|
+
VISIBLE BOTH SAEM 5 AN 4
|
27
|
+
VISIBLE BOTH SAEM 4 AN 4
|
28
|
+
VISIBLE DIFFRINT 4 AN 3
|
29
|
+
VISIBLE DIFFRINT 5.22 5.22
|
30
|
+
KTHXBYE
|
@@ -0,0 +1,28 @@
|
|
1
|
+
HAI 1.2
|
2
|
+
I HAS A var
|
3
|
+
VISIBLE MAEK var A YARN
|
4
|
+
VISIBLE MAEK var A NUMBR
|
5
|
+
VISIBLE MAEK var A NUMBAR
|
6
|
+
VISIBLE MAEK var A TROOF
|
7
|
+
|
8
|
+
VISIBLE MAEK "abc" A YARN
|
9
|
+
VISIBLE MAEK "-19" A NUMBR
|
10
|
+
VISIBLE MAEK "22.56" A NUMBAR
|
11
|
+
VISIBLE MAEK "abc" A TROOF
|
12
|
+
|
13
|
+
VISIBLE MAEK 12 A YARN
|
14
|
+
VISIBLE MAEK 12 A NUMBR
|
15
|
+
VISIBLE MAEK 12 A NUMBAR
|
16
|
+
VISIBLE MAEK 12 A TROOF
|
17
|
+
|
18
|
+
VISIBLE MAEK WIN A YARN
|
19
|
+
VISIBLE MAEK WIN A NUMBR
|
20
|
+
VISIBLE MAEK WIN A NUMBAR
|
21
|
+
VISIBLE MAEK WIN A TROOF
|
22
|
+
|
23
|
+
VISIBLE MAEK FAIL A YARN
|
24
|
+
VISIBLE MAEK FAIL A NUMBR
|
25
|
+
VISIBLE MAEK FAIL A NUMBAR
|
26
|
+
VISIBLE MAEK FAIL A TROOF
|
27
|
+
|
28
|
+
KTHXBYE
|
@@ -0,0 +1,24 @@
|
|
1
|
+
HAI 1.2
|
2
|
+
|
3
|
+
HOW DUZ I x_mul_y_plus_z YR x AN YR y AN YR z
|
4
|
+
I HAS A var ITZ PRODUKT OF x AN y
|
5
|
+
var R SUM OF var AN z
|
6
|
+
FOUND YR var
|
7
|
+
IF U SAY SO
|
8
|
+
|
9
|
+
VISIBLE "1 * 2 + 3 = " x_mul_y_plus_z 1 2 3 " one more arg for VISIBLE"
|
10
|
+
|
11
|
+
BTW This function uses implicit variable to return value, just like in Ruby
|
12
|
+
HOW DUZ I greeting YR name
|
13
|
+
SMOOSH "Greetings, " AN name
|
14
|
+
IF U SAY SO
|
15
|
+
|
16
|
+
VISIBLE greeting "Shrek"
|
17
|
+
VISIBLE greeting "Princess Fiona"
|
18
|
+
|
19
|
+
HOW DUZ I nil_func
|
20
|
+
GTFO
|
21
|
+
IF U SAY SO
|
22
|
+
|
23
|
+
VISIBLE MAEK nil_func A NUMBR
|
24
|
+
KTHXBYE
|
@@ -0,0 +1,20 @@
|
|
1
|
+
HAI 1.2
|
2
|
+
I HAS A str ITZ SMOOSH "Hello " "World"
|
3
|
+
VISIBLE str
|
4
|
+
|
5
|
+
BTW SMOOSH operator concatenates all arguments
|
6
|
+
VISIBLE SMOOSH "Let " AN "me " AN "be " AN "with " AN "you" MKAY "!"
|
7
|
+
|
8
|
+
BTW Escape sequences
|
9
|
+
VISIBLE "Escape sequences :) :>:" :::""
|
10
|
+
|
11
|
+
BTW Unicode code points and normative names
|
12
|
+
VISIBLE "Unicode :(2A), :[LATIN CAPITAL LETTER A]"
|
13
|
+
|
14
|
+
BTW Variable interpolation
|
15
|
+
I HAS A name ITZ "Alice"
|
16
|
+
VISIBLE "Hello :{name}"
|
17
|
+
SUM OF 2 AN 3
|
18
|
+
VISIBLE "2 + 3 = :{IT}"
|
19
|
+
|
20
|
+
KTHXBYE
|
@@ -0,0 +1,42 @@
|
|
1
|
+
HAI 1.2
|
2
|
+
|
3
|
+
I HAS A animal ITZ "fish"
|
4
|
+
|
5
|
+
BOTH SAEM animal AN "fish", O RLY?
|
6
|
+
YA RLY
|
7
|
+
VISIBLE "I hav a fish"
|
8
|
+
MEBBE BOTH SAEM animal AN "cat"
|
9
|
+
VISIBLE "I hav a cat"
|
10
|
+
MEBBE BOTH SAEM animal AN "dog"
|
11
|
+
VISIBLE "I hav a dog"
|
12
|
+
NO WAI
|
13
|
+
VISIBLE "I hav unknown creature"
|
14
|
+
OIC
|
15
|
+
|
16
|
+
animal R "cat"
|
17
|
+
|
18
|
+
BOTH SAEM animal AN "fish", O RLY?
|
19
|
+
YA RLY
|
20
|
+
VISIBLE "I hav a fish"
|
21
|
+
MEBBE BOTH SAEM animal AN "cat"
|
22
|
+
VISIBLE "I hav a cat"
|
23
|
+
MEBBE BOTH SAEM animal AN "dog"
|
24
|
+
VISIBLE "I hav a dog"
|
25
|
+
NO WAI
|
26
|
+
VISIBLE "I hav unknown creature"
|
27
|
+
OIC
|
28
|
+
|
29
|
+
animal R "robot"
|
30
|
+
|
31
|
+
BOTH SAEM animal AN "fish", O RLY?
|
32
|
+
YA RLY
|
33
|
+
VISIBLE "I hav a fish"
|
34
|
+
MEBBE BOTH SAEM animal AN "cat"
|
35
|
+
VISIBLE "I hav a cat"
|
36
|
+
MEBBE BOTH SAEM animal AN "dog"
|
37
|
+
VISIBLE "I hav a dog"
|
38
|
+
NO WAI
|
39
|
+
VISIBLE "I hav unknown creature"
|
40
|
+
OIC
|
41
|
+
|
42
|
+
KTHXBYE
|
@@ -0,0 +1 @@
|
|
1
|
+
Alisa
|