kaiser-ruby 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -0
- data/TODO.md +2 -2
- data/lib/kaiser_ruby/rockstar_parser.rb +10 -6
- data/lib/kaiser_ruby/rockstar_transform.rb +2 -1
- data/lib/kaiser_ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b9d062d700db52c37367a613f89ff577927d8b013bfea6d994e0eda03e26758
|
4
|
+
data.tar.gz: 6082e82328bdb866c38c50eb2765984bbded0c29c81ef2ca14fdaaee87f83a21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 470d1fd4008cae879d727e0de6f99abe5f3261067dbf738e70f9431f4e2c7cd04100ea64621fffefb8c6c1830821f020767d7b83209cf9f9304f4df098b0faf4
|
7
|
+
data.tar.gz: 41825a7a6f9bad109f36c3a2984960c9d7c4b23d27fa7aef2f60ef2ecdc6872f49898aba9793cb3c1ae8a0728c93b34d772e75da147c7f6ebae4cdd94ceb630d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -49,6 +49,22 @@ Saved output in `a.rb`
|
|
49
49
|
|
50
50
|
```
|
51
51
|
|
52
|
+
Another option is to run an interactive console (REPL):
|
53
|
+
|
54
|
+
```
|
55
|
+
$ kaiser-ruby rock --debug
|
56
|
+
Type 'exit' to exit the console. Otherwise, rock on!
|
57
|
+
\m/> Put "Hello San Francisco" into the message
|
58
|
+
\m/> the_message = "Hello San Francisco"
|
59
|
+
=> Hello San Francisco
|
60
|
+
\m/> Scream the message
|
61
|
+
\m/> puts the_message
|
62
|
+
Hello San Francisco
|
63
|
+
=> nil
|
64
|
+
\m/> exit
|
65
|
+
$
|
66
|
+
```
|
67
|
+
|
52
68
|
Finally, you can also transpile and immediately execute the code, like this:
|
53
69
|
|
54
70
|
```
|
data/TODO.md
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
|
7
7
|
## Types
|
8
8
|
|
9
|
-
- [
|
10
|
-
- [
|
9
|
+
- [x] Handle null type differently - nil in Ruby isn't really comparable to 0
|
10
|
+
- [x] Handle mysterious type - probably this should be nil and what is now nil should be 0 instead
|
11
11
|
- [ ] Handle object type
|
12
12
|
|
13
13
|
## Comparisons
|
@@ -1,11 +1,14 @@
|
|
1
1
|
module KaiserRuby
|
2
2
|
class RockstarParser < Parslet::Parser
|
3
3
|
rule(:reserved) do
|
4
|
-
|
5
|
-
|
4
|
+
mysterious_value_keywords | null_value_keywords | true_value_keywords | false_value_keywords |
|
5
|
+
plus_keywords | minus_keywords | times_keywords | over_keywords |
|
6
|
+
str('Knock') | str('Build') | str('Put') | str('into') | str('says') |
|
7
|
+
poetic_number_keywords | say_keywords
|
6
8
|
end
|
7
9
|
|
8
|
-
rule(:
|
10
|
+
rule(:mysterious_value_keywords) { str('mysterious') }
|
11
|
+
rule(:null_value_keywords) { str('nothing') | str('nowhere') | str('nobody') | str('empty') | str('gone') }
|
9
12
|
rule(:false_value_keywords) { str('false') | str('wrong') | str('no') | str('lies') }
|
10
13
|
rule(:true_value_keywords) { str('true') | str('right') | str('yes') | str('ok') }
|
11
14
|
rule(:plus_keywords) { str('plus') | str('with') }
|
@@ -35,7 +38,8 @@ module KaiserRuby
|
|
35
38
|
(common_variable_name | proper_variable_name).as(:variable_name)
|
36
39
|
end
|
37
40
|
|
38
|
-
rule(:
|
41
|
+
rule(:mysterious_value) { mysterious_value_keywords.as(:mysterious_value) }
|
42
|
+
rule(:null_value) { null_value_keywords.as(:null_value) }
|
39
43
|
rule(:true_value) { true_value_keywords.as(:true_value) }
|
40
44
|
rule(:false_value) { false_value_keywords.as(:false_value) }
|
41
45
|
rule(:string_value) { (str('"') >> match['[[:alpha:]] '].repeat >> str('"')).as(:string_value) }
|
@@ -97,7 +101,7 @@ module KaiserRuby
|
|
97
101
|
rule(:poetic_type_literal) do
|
98
102
|
(flow_keywords.absent?) >>
|
99
103
|
(
|
100
|
-
variable_names.as(:left) >> str(' is ') >> (
|
104
|
+
variable_names.as(:left) >> str(' is ') >> (mysterious_value | null_value | false_value | true_value).as(:right)
|
101
105
|
).as(:assignment)
|
102
106
|
end
|
103
107
|
|
@@ -154,7 +158,7 @@ module KaiserRuby
|
|
154
158
|
).as(:if_else)
|
155
159
|
end
|
156
160
|
|
157
|
-
rule(:simple_values) {
|
161
|
+
rule(:simple_values) { mysterious_value | null_value | false_value | true_value | string_value | numeric_value }
|
158
162
|
rule(:value_or_variable) { variable_names | simple_values }
|
159
163
|
rule(:expressions) { basic_assignment_expression | increment | decrement | addition | subtraction | multiplication | division }
|
160
164
|
rule(:comparisons) { equality }
|
@@ -3,7 +3,8 @@ module KaiserRuby
|
|
3
3
|
class RockstarTransform < Parslet::Transform
|
4
4
|
rule(variable_name: simple(:str)) { |c| parameterize(c[:str]) }
|
5
5
|
|
6
|
-
rule(
|
6
|
+
rule(mysterious_value: simple(:_)) { 'nil' }
|
7
|
+
rule(null_value: simple(:_)) { '0' }
|
7
8
|
rule(true_value: simple(:_)) { 'true' }
|
8
9
|
rule(false_value: simple(:_)) { 'false' }
|
9
10
|
rule(string_value: simple(:str)) { str }
|
data/lib/kaiser_ruby/version.rb
CHANGED