code-ruby 1.8.5 → 1.8.6
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/code/parser/boolean.rb +6 -2
- data/lib/code/parser/call.rb +7 -3
- data/lib/code/parser/function.rb +7 -3
- data/lib/code/parser/group.rb +7 -3
- data/lib/code/parser/if.rb +13 -9
- data/lib/code/parser/if_modifier.rb +8 -4
- data/lib/code/parser/not_keyword.rb +5 -1
- data/lib/code/parser/nothing.rb +5 -1
- data/lib/code/parser/or_keyword.rb +6 -2
- data/lib/code/parser/while.rb +10 -6
- data/spec/code/object/list_spec.rb +0 -2
- data/spec/code_spec.rb +16 -0
- 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: 632c4d8078df7ff5a5b016cf91ab315d82ff5995b31717fa5ec310fdcd2b6ae4
|
|
4
|
+
data.tar.gz: 624eab7bba2cb63fe5f14ea683ebccb9cfbc9f199e04ceff683d954b382ebb59
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a294f0431f0fa43aa92de41b7645ebc9175747fcfa4b9e8b83c7437e468dd401e44ee96885534edbc393eddd21c13729534bf48c09fdc13f018cfe315bd5d38
|
|
7
|
+
data.tar.gz: 75424da0a2d062d0439fd1d6a17eb58b4476b67528e1814c335f04c9c167e2310667bce071a2b4cd781758ab239c598620f416ef58caf9fa6b71b66e0fb3e653
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.8.
|
|
1
|
+
1.8.6
|
data/lib/code/parser/boolean.rb
CHANGED
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
class Code
|
|
4
4
|
class Parser
|
|
5
5
|
class Boolean < Language
|
|
6
|
+
def separator
|
|
7
|
+
Name.new.separator
|
|
8
|
+
end
|
|
9
|
+
|
|
6
10
|
def true_keyword
|
|
7
|
-
str("true")
|
|
11
|
+
str("true") << separator.present
|
|
8
12
|
end
|
|
9
13
|
|
|
10
14
|
def false_keyword
|
|
11
|
-
str("false")
|
|
15
|
+
str("false") << separator.present
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
def root
|
data/lib/code/parser/call.rb
CHANGED
|
@@ -55,16 +55,20 @@ class Code
|
|
|
55
55
|
str(")")
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
def separator
|
|
59
|
+
Name.new.separator
|
|
60
|
+
end
|
|
61
|
+
|
|
58
62
|
def do_keyword
|
|
59
|
-
str("do")
|
|
63
|
+
str("do") << separator.present
|
|
60
64
|
end
|
|
61
65
|
|
|
62
66
|
def begin_keyword
|
|
63
|
-
str("do")
|
|
67
|
+
str("do") << separator.present
|
|
64
68
|
end
|
|
65
69
|
|
|
66
70
|
def end_keyword
|
|
67
|
-
str("end")
|
|
71
|
+
str("end") << separator.present
|
|
68
72
|
end
|
|
69
73
|
|
|
70
74
|
def asterisk
|
data/lib/code/parser/function.rb
CHANGED
|
@@ -23,16 +23,20 @@ class Code
|
|
|
23
23
|
whitespace.maybe
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
def separator
|
|
27
|
+
Name.new.separator
|
|
28
|
+
end
|
|
29
|
+
|
|
26
30
|
def do_keyword
|
|
27
|
-
str("do")
|
|
31
|
+
str("do") << separator.present
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def begin_keyword
|
|
31
|
-
str("begin")
|
|
35
|
+
str("begin") << separator.present
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def end_keyword
|
|
35
|
-
str("end")
|
|
39
|
+
str("end") << separator.present
|
|
36
40
|
end
|
|
37
41
|
|
|
38
42
|
def spread_operator
|
data/lib/code/parser/group.rb
CHANGED
|
@@ -23,16 +23,20 @@ class Code
|
|
|
23
23
|
str(")")
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
def separator
|
|
27
|
+
Name.new.separator
|
|
28
|
+
end
|
|
29
|
+
|
|
26
30
|
def end_keyword
|
|
27
|
-
str("end")
|
|
31
|
+
str("end") << separator.present
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def do_keyword
|
|
31
|
-
str("do")
|
|
35
|
+
str("do") << separator.present
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def begin_keyword
|
|
35
|
-
str("begin")
|
|
39
|
+
str("begin") << separator.present
|
|
36
40
|
end
|
|
37
41
|
|
|
38
42
|
def root
|
data/lib/code/parser/if.rb
CHANGED
|
@@ -23,12 +23,16 @@ class Code
|
|
|
23
23
|
whitespace.maybe
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
def separator
|
|
27
|
+
Name.new.separator
|
|
28
|
+
end
|
|
29
|
+
|
|
26
30
|
def do_keyword
|
|
27
|
-
str("do")
|
|
31
|
+
str("do") << separator.present
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def begin_keyword
|
|
31
|
-
str("begin")
|
|
35
|
+
str("begin") << separator.present
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def opening_curly_bracket
|
|
@@ -36,31 +40,31 @@ class Code
|
|
|
36
40
|
end
|
|
37
41
|
|
|
38
42
|
def closing_curly_bracket
|
|
39
|
-
str("
|
|
43
|
+
str("}")
|
|
40
44
|
end
|
|
41
45
|
|
|
42
46
|
def if_keyword
|
|
43
|
-
str("if")
|
|
47
|
+
str("if") << separator.present
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def unless_keyword
|
|
47
|
-
str("unless")
|
|
51
|
+
str("unless") << separator.present
|
|
48
52
|
end
|
|
49
53
|
|
|
50
54
|
def elsif_keyword
|
|
51
|
-
str("elsif")
|
|
55
|
+
str("elsif") << separator.present
|
|
52
56
|
end
|
|
53
57
|
|
|
54
58
|
def elsunless_keyword
|
|
55
|
-
str("elsunless")
|
|
59
|
+
str("elsunless") << separator.present
|
|
56
60
|
end
|
|
57
61
|
|
|
58
62
|
def else_keyword
|
|
59
|
-
str("else")
|
|
63
|
+
str("else") << separator.present
|
|
60
64
|
end
|
|
61
65
|
|
|
62
66
|
def end_keyword
|
|
63
|
-
str("end")
|
|
67
|
+
str("end") << separator.present
|
|
64
68
|
end
|
|
65
69
|
|
|
66
70
|
def body
|
|
@@ -11,20 +11,24 @@ class Code
|
|
|
11
11
|
Whitespace.new.without_newline
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def separator
|
|
15
|
+
Name.new.separator
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
def if_keyword
|
|
15
|
-
str("if")
|
|
19
|
+
str("if") << separator.present
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
def unless_keyword
|
|
19
|
-
str("unless")
|
|
23
|
+
str("unless") << separator.present
|
|
20
24
|
end
|
|
21
25
|
|
|
22
26
|
def while_keyword
|
|
23
|
-
str("while")
|
|
27
|
+
str("while") << separator.present
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
def until_keyword
|
|
27
|
-
str("until")
|
|
31
|
+
str("until") << separator.present
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def operator
|
data/lib/code/parser/nothing.rb
CHANGED
|
@@ -7,12 +7,16 @@ class Code
|
|
|
7
7
|
NotKeyword
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
def separator
|
|
11
|
+
Name.new.separator
|
|
12
|
+
end
|
|
13
|
+
|
|
10
14
|
def or_keyword
|
|
11
|
-
str("or")
|
|
15
|
+
str("or") << separator.present
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
def and_keyword
|
|
15
|
-
str("and")
|
|
19
|
+
str("and") << separator.present
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
def operator
|
data/lib/code/parser/while.rb
CHANGED
|
@@ -19,28 +19,32 @@ class Code
|
|
|
19
19
|
Code
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def separator
|
|
23
|
+
Name.new.separator
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
def while_keyword
|
|
23
|
-
str("while")
|
|
27
|
+
str("while") << separator.present
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
def until_keyword
|
|
27
|
-
str("until")
|
|
31
|
+
str("until") << separator.present
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def end_keyword
|
|
31
|
-
str("end")
|
|
35
|
+
str("end") << separator.present
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def do_keyword
|
|
35
|
-
str("do")
|
|
39
|
+
str("do") << separator.present
|
|
36
40
|
end
|
|
37
41
|
|
|
38
42
|
def begin_keyword
|
|
39
|
-
str("begin")
|
|
43
|
+
str("begin") << separator.present
|
|
40
44
|
end
|
|
41
45
|
|
|
42
46
|
def loop_keyword
|
|
43
|
-
str("loop")
|
|
47
|
+
str("loop") << separator.present
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def opening_curly_bracket
|
|
@@ -8,8 +8,6 @@ RSpec.describe Code::Object::List do
|
|
|
8
8
|
["[1, 2, 3].sum", "6"],
|
|
9
9
|
["[1, 2] + [3, 4]", "[1, 2, 3, 4]"],
|
|
10
10
|
["[] + []", "[]"],
|
|
11
|
-
["[1].any", "true"],
|
|
12
|
-
["[].any", "false"]
|
|
13
11
|
].each do |input, expected|
|
|
14
12
|
it "#{input} == #{expected}" do
|
|
15
13
|
expect(Code.evaluate(input)).to eq(Code.evaluate(expected))
|
data/spec/code_spec.rb
CHANGED
|
@@ -330,6 +330,22 @@ RSpec.describe Code do
|
|
|
330
330
|
["if true 1", "1"],
|
|
331
331
|
["not not false", "false"],
|
|
332
332
|
["not true", "false"],
|
|
333
|
+
["a = 1 orirginal = 2 orirginal", "2"],
|
|
334
|
+
["a = 1 andy = 2 andy", "2"],
|
|
335
|
+
["ifonly = 1 ifonly", "1"],
|
|
336
|
+
["unlessy = 2 unlessy", "2"],
|
|
337
|
+
["elsiffy = 3 elsiffy", "3"],
|
|
338
|
+
["elsunlessy = 4 elsunlessy", "4"],
|
|
339
|
+
["elsewhere = 5 elsewhere", "5"],
|
|
340
|
+
["whiley = 6 whiley", "6"],
|
|
341
|
+
["untily = 7 untily", "7"],
|
|
342
|
+
["looped = 8 looped", "8"],
|
|
343
|
+
["doable = 9 doable", "9"],
|
|
344
|
+
["beginner = 10 beginner", "10"],
|
|
345
|
+
["endless = 11 endless", "11"],
|
|
346
|
+
["trueblue = 12 trueblue", "12"],
|
|
347
|
+
["falsey = 13 falsey", "13"],
|
|
348
|
+
["nothingness = 14 nothingness", "14"],
|
|
333
349
|
["random = 1 random", "1"],
|
|
334
350
|
["true && false", "false"],
|
|
335
351
|
["true && true", "true"],
|