code-ruby 2.0.1 → 3.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/VERSION +1 -1
  4. data/lib/code/format.rb +4 -2
  5. data/lib/code/parser.rb +1113 -6
  6. data/lib/code-ruby.rb +0 -1
  7. data/spec/code/node/call_spec.rb +10 -0
  8. data/spec/code/parser/boolean_spec.rb +1 -1
  9. data/spec/code/parser/chained_call_spec.rb +1 -1
  10. data/spec/code/parser/dictionary_spec.rb +3 -2
  11. data/spec/code/parser/function_spec.rb +3 -2
  12. data/spec/code/parser/group_spec.rb +1 -1
  13. data/spec/code/parser/if_modifier_spec.rb +1 -1
  14. data/spec/code/parser/list_spec.rb +1 -1
  15. data/spec/code/parser/number_spec.rb +1 -1
  16. data/spec/code/parser/string_spec.rb +1 -1
  17. data/spec/code_spec.rb +2 -1
  18. metadata +1 -41
  19. data/lib/code/parser/addition.rb +0 -23
  20. data/lib/code/parser/and_operator.rb +0 -19
  21. data/lib/code/parser/bitwise_and.rb +0 -23
  22. data/lib/code/parser/bitwise_or.rb +0 -23
  23. data/lib/code/parser/boolean.rb +0 -23
  24. data/lib/code/parser/call.rb +0 -161
  25. data/lib/code/parser/chained_call.rb +0 -31
  26. data/lib/code/parser/class.rb +0 -15
  27. data/lib/code/parser/code.rb +0 -27
  28. data/lib/code/parser/dictionary.rb +0 -72
  29. data/lib/code/parser/equal.rb +0 -67
  30. data/lib/code/parser/equality.rb +0 -42
  31. data/lib/code/parser/function.rb +0 -131
  32. data/lib/code/parser/greater.rb +0 -32
  33. data/lib/code/parser/group.rb +0 -58
  34. data/lib/code/parser/if.rb +0 -101
  35. data/lib/code/parser/if_modifier.rb +0 -39
  36. data/lib/code/parser/left_operation.rb +0 -44
  37. data/lib/code/parser/list.rb +0 -47
  38. data/lib/code/parser/multiplication.rb +0 -39
  39. data/lib/code/parser/name.rb +0 -188
  40. data/lib/code/parser/negation.rb +0 -32
  41. data/lib/code/parser/not_keyword.rb +0 -29
  42. data/lib/code/parser/nothing.rb +0 -19
  43. data/lib/code/parser/number.rb +0 -156
  44. data/lib/code/parser/or_keyword.rb +0 -27
  45. data/lib/code/parser/or_operator.rb +0 -19
  46. data/lib/code/parser/power.rb +0 -19
  47. data/lib/code/parser/range.rb +0 -19
  48. data/lib/code/parser/rescue.rb +0 -19
  49. data/lib/code/parser/right_operation.rb +0 -44
  50. data/lib/code/parser/shift.rb +0 -23
  51. data/lib/code/parser/splat.rb +0 -33
  52. data/lib/code/parser/square_bracket.rb +0 -44
  53. data/lib/code/parser/statement.rb +0 -11
  54. data/lib/code/parser/string.rb +0 -81
  55. data/lib/code/parser/ternary.rb +0 -45
  56. data/lib/code/parser/unary_minus.rb +0 -33
  57. data/lib/code/parser/while.rb +0 -81
  58. data/lib/code/parser/whitespace.rb +0 -51
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Code
4
- class Parser
5
- class String < Language
6
- def code
7
- Code
8
- end
9
-
10
- def name
11
- Name
12
- end
13
-
14
- def single_quote
15
- str("'")
16
- end
17
-
18
- def double_quote
19
- str('"')
20
- end
21
-
22
- def backslash
23
- str('\\')
24
- end
25
-
26
- def opening_curly_bracket
27
- str("{")
28
- end
29
-
30
- def closing_curly_bracket
31
- str("}")
32
- end
33
-
34
- def colon
35
- str(":")
36
- end
37
-
38
- def code_part
39
- opening_curly_bracket.ignore << code <<
40
- closing_curly_bracket.maybe.ignore
41
- end
42
-
43
- def single_quoted_text_part
44
- (
45
- (backslash.ignore << opening_curly_bracket) |
46
- (backslash.ignore << single_quote) |
47
- (single_quote.absent << opening_curly_bracket.absent << any)
48
- ).repeat(1)
49
- end
50
-
51
- def double_quoted_text_part
52
- (
53
- (backslash.ignore << opening_curly_bracket) |
54
- (backslash.ignore << double_quote) |
55
- (double_quote.absent << opening_curly_bracket.absent << any)
56
- ).repeat(1)
57
- end
58
-
59
- def single_quoted_string
60
- single_quote.ignore << (
61
- code_part.aka(:code) | single_quoted_text_part.aka(:text)
62
- ).repeat << single_quote.ignore.maybe
63
- end
64
-
65
- def double_quoted_string
66
- double_quote.ignore << (
67
- code_part.aka(:code) | double_quoted_text_part.aka(:text)
68
- ).repeat << double_quote.ignore.maybe
69
- end
70
-
71
- def symbol
72
- (colon.ignore << name).aka(:text).repeat(1, 1)
73
- end
74
-
75
- def root
76
- (single_quoted_string | double_quoted_string | symbol).aka(:string) |
77
- Number
78
- end
79
- end
80
- end
81
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Code
4
- class Parser
5
- class Ternary < Language
6
- def statement
7
- Range
8
- end
9
-
10
- def ternary
11
- Ternary
12
- end
13
-
14
- def whitespace
15
- Whitespace
16
- end
17
-
18
- def whitespace?
19
- whitespace.maybe
20
- end
21
-
22
- def question_mark
23
- str("?")
24
- end
25
-
26
- def colon
27
- str(":")
28
- end
29
-
30
- def root
31
- (
32
- statement.aka(:left) << (
33
- whitespace? << question_mark << whitespace? <<
34
- ternary.aka(:middle) <<
35
- (whitespace? << colon << whitespace? << ternary.aka(:right)).maybe
36
- ).maybe
37
- )
38
- .aka(:ternary)
39
- .then do |output|
40
- output[:ternary][:middle] ? output : output[:ternary][:left]
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Code
4
- class Parser
5
- class UnaryMinus < Language
6
- def unary_minus
7
- UnaryMinus
8
- end
9
-
10
- def whitespace
11
- Whitespace
12
- end
13
-
14
- def whitespace?
15
- whitespace.maybe
16
- end
17
-
18
- def minus
19
- str("-")
20
- end
21
-
22
- def operator
23
- minus
24
- end
25
-
26
- def root
27
- (operator.aka(:operator) << whitespace? << unary_minus.aka(:right)).aka(
28
- :unary_minus
29
- ) | Power
30
- end
31
- end
32
- end
33
- end
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Code
4
- class Parser
5
- class While < Language
6
- def statement
7
- If
8
- end
9
-
10
- def whitespace
11
- Whitespace
12
- end
13
-
14
- def whitespace?
15
- whitespace.maybe
16
- end
17
-
18
- def code
19
- Code
20
- end
21
-
22
- def separator
23
- Name.new.separator
24
- end
25
-
26
- def while_keyword
27
- str("while") << separator.present
28
- end
29
-
30
- def until_keyword
31
- str("until") << separator.present
32
- end
33
-
34
- def end_keyword
35
- str("end") << separator.present
36
- end
37
-
38
- def do_keyword
39
- str("do") << separator.present
40
- end
41
-
42
- def begin_keyword
43
- str("begin") << separator.present
44
- end
45
-
46
- def loop_keyword
47
- str("loop") << separator.present
48
- end
49
-
50
- def opening_curly_bracket
51
- str("{")
52
- end
53
-
54
- def closing_curly_bracket
55
- str("}")
56
- end
57
-
58
- def body
59
- (
60
- (begin_keyword | do_keyword).ignore << whitespace << code <<
61
- (whitespace? << end_keyword).maybe.ignore
62
- ) |
63
- (
64
- opening_curly_bracket.ignore << whitespace? << code <<
65
- (whitespace? << closing_curly_bracket).maybe.ignore
66
- ) | (code << (whitespace? << end_keyword).maybe.ignore)
67
- end
68
-
69
- def root
70
- (
71
- (
72
- (
73
- (while_keyword | until_keyword).aka(:operator) << whitespace <<
74
- statement.aka(:statement)
75
- ) | (loop_keyword.aka(:operator) << whitespace)
76
- ) << body.aka(:body)
77
- ).aka(:while) | statement
78
- end
79
- end
80
- end
81
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Code
4
- class Parser
5
- class Whitespace < Language
6
- def space
7
- str(" ")
8
- end
9
-
10
- def newline
11
- str("\n") | str("\r")
12
- end
13
-
14
- def hashtag
15
- str("#")
16
- end
17
-
18
- def slash
19
- str("/")
20
- end
21
-
22
- def asterisk
23
- str("*")
24
- end
25
-
26
- def hash_comment
27
- hashtag << (newline.absent << any).repeat << newline.maybe
28
- end
29
-
30
- def double_slash_comment
31
- slash << slash << (newline.absent << any).repeat << newline.maybe
32
- end
33
-
34
- def multi_line_comment
35
- slash << asterisk << ((asterisk << slash).absent << any).repeat <<
36
- asterisk.maybe << slash.maybe
37
- end
38
-
39
- def without_newline
40
- (space | multi_line_comment).repeat(1).ignore
41
- end
42
-
43
- def root
44
- (
45
- space | newline | hash_comment | double_slash_comment |
46
- multi_line_comment
47
- ).repeat(1).ignore | any.absent
48
- end
49
- end
50
- end
51
- end