code-ruby-parser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.overcommit.yml +4 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +32 -0
  6. data/bin/code-parser +27 -0
  7. data/bin/format +3 -0
  8. data/bin/template-parser +27 -0
  9. data/docs/class.code +9 -0
  10. data/docs/meetup.code +14 -0
  11. data/docs/rain.code +23 -0
  12. data/docs/slack.code +17 -0
  13. data/docs/stripe.code +7 -0
  14. data/docs/twitter.code +7 -0
  15. data/lib/code/parser/addition.rb +13 -0
  16. data/lib/code/parser/and_operator.rb +13 -0
  17. data/lib/code/parser/bitwise_and.rb +13 -0
  18. data/lib/code/parser/bitwise_or.rb +13 -0
  19. data/lib/code/parser/boolean.rb +13 -0
  20. data/lib/code/parser/call.rb +174 -0
  21. data/lib/code/parser/chained_call.rb +41 -0
  22. data/lib/code/parser/class.rb +56 -0
  23. data/lib/code/parser/code.rb +20 -0
  24. data/lib/code/parser/comments.rb +46 -0
  25. data/lib/code/parser/dictionnary.rb +48 -0
  26. data/lib/code/parser/equal.rb +39 -0
  27. data/lib/code/parser/equality.rb +20 -0
  28. data/lib/code/parser/error/syntax_error.rb +36 -0
  29. data/lib/code/parser/error.rb +6 -0
  30. data/lib/code/parser/function.rb +109 -0
  31. data/lib/code/parser/greater_than.rb +13 -0
  32. data/lib/code/parser/group.rb +15 -0
  33. data/lib/code/parser/identifier.rb +54 -0
  34. data/lib/code/parser/if.rb +81 -0
  35. data/lib/code/parser/if_modifier.rb +39 -0
  36. data/lib/code/parser/list.rb +20 -0
  37. data/lib/code/parser/multiplication.rb +13 -0
  38. data/lib/code/parser/negation.rb +18 -0
  39. data/lib/code/parser/not_keyword.rb +24 -0
  40. data/lib/code/parser/nothing.rb +13 -0
  41. data/lib/code/parser/number.rb +39 -0
  42. data/lib/code/parser/operation.rb +44 -0
  43. data/lib/code/parser/or_keyword.rb +13 -0
  44. data/lib/code/parser/or_operator.rb +13 -0
  45. data/lib/code/parser/power.rb +33 -0
  46. data/lib/code/parser/range.rb +13 -0
  47. data/lib/code/parser/rescue.rb +38 -0
  48. data/lib/code/parser/shift.rb +13 -0
  49. data/lib/code/parser/statement.rb +9 -0
  50. data/lib/code/parser/string.rb +61 -0
  51. data/lib/code/parser/ternary.rb +73 -0
  52. data/lib/code/parser/unary_minus.rb +23 -0
  53. data/lib/code/parser/while.rb +36 -0
  54. data/lib/code/parser.rb +237 -0
  55. data/lib/code-ruby-parser.rb +7 -0
  56. data/lib/code.rb +2 -0
  57. data/lib/template/parser.rb +32 -0
  58. data/lib/template-ruby-parser.rb +7 -0
  59. data/lib/template.rb +2 -0
  60. data/spec/code/parser/addition_spec.rb +26 -0
  61. data/spec/code/parser/and_operator_spec.rb +26 -0
  62. data/spec/code/parser/bitwise_and_spec.rb +26 -0
  63. data/spec/code/parser/bitwise_or_spec.rb +26 -0
  64. data/spec/code/parser/boolean_spec.rb +13 -0
  65. data/spec/code/parser/call_spec.rb +52 -0
  66. data/spec/code/parser/chained_call_spec.rb +33 -0
  67. data/spec/code/parser/class_spec.rb +32 -0
  68. data/spec/code/parser/code_spec.rb +13 -0
  69. data/spec/code/parser/dictionnary_spec.rb +40 -0
  70. data/spec/code/parser/equal_spec.rb +42 -0
  71. data/spec/code/parser/equality_spec.rb +26 -0
  72. data/spec/code/parser/function_spec.rb +43 -0
  73. data/spec/code/parser/greater_than_spec.rb +26 -0
  74. data/spec/code/parser/group_spec.rb +13 -0
  75. data/spec/code/parser/if_modifier_spec.rb +26 -0
  76. data/spec/code/parser/if_spec.rb +39 -0
  77. data/spec/code/parser/list_spec.rb +27 -0
  78. data/spec/code/parser/multiplication_spec.rb +26 -0
  79. data/spec/code/parser/negation_spec.rb +13 -0
  80. data/spec/code/parser/not_keyword_spec.rb +21 -0
  81. data/spec/code/parser/nothing_spec.rb +20 -0
  82. data/spec/code/parser/number_spec.rb +24 -0
  83. data/spec/code/parser/or_keyword_spec.rb +26 -0
  84. data/spec/code/parser/or_operator_spec.rb +26 -0
  85. data/spec/code/parser/power_spec.rb +21 -0
  86. data/spec/code/parser/range_spec.rb +21 -0
  87. data/spec/code/parser/rescue_spec.rb +26 -0
  88. data/spec/code/parser/shift_spec.rb +26 -0
  89. data/spec/code/parser/string_spec.rb +27 -0
  90. data/spec/code/parser/ternary_spec.rb +26 -0
  91. data/spec/code/parser/unary_minus_spec.rb +21 -0
  92. data/spec/code/parser/while_spec.rb +32 -0
  93. data/spec/spec_helper.rb +6 -0
  94. data/spec/template/parser_spec.rb +13 -0
  95. data/template-ruby-parser.gemspec +16 -0
  96. metadata +171 -0
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe ::Code::Parser do
4
+ subject { ::Code::Parser.parse(input) }
5
+
6
+ [
7
+ "''",
8
+ '""',
9
+ ":a",
10
+ "'Hello Dorian'",
11
+ '"Hello Dorian"',
12
+ "'Hello \\' Dorian'",
13
+ '"Hello \\" Dorian"',
14
+ "'Hello \\{name}'",
15
+ '"Hello \\{name}',
16
+ "'Hello {name}'",
17
+ '"Hello {name}',
18
+ '"Hello \\n\\a\\{"',
19
+ "'Hello \\n\\a\\{'"
20
+ ].each do |input|
21
+ context input do
22
+ let!(:input) { input }
23
+
24
+ it { expect { subject }.to_not raise_error }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe ::Code::Parser do
4
+ subject { ::Code::Parser.parse(input) }
5
+
6
+ ["a ? b : c", "a ? b", "a ? b ? c : d : e", "a ? b ? c : d"].each do |input|
7
+ context input do
8
+ let!(:input) { input }
9
+
10
+ it { expect { subject }.to_not raise_error }
11
+ end
12
+ end
13
+
14
+ [
15
+ "a /* cool */ ? b : c",
16
+ "a ? /* cool */ b",
17
+ "a ? b /* cool */ ? c : d : e",
18
+ "a ? b ? /* cool */ c : d"
19
+ ].each do |input|
20
+ context input do
21
+ let!(:input) { input }
22
+
23
+ it { expect(subject.to_json).to include("cool") }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe ::Code::Parser do
4
+ subject { ::Code::Parser.parse(input) }
5
+
6
+ %w[-1 +a -+--1].each do |input|
7
+ context input do
8
+ let!(:input) { input }
9
+
10
+ it { expect { subject }.to_not raise_error }
11
+ end
12
+ end
13
+
14
+ ["- /* cool */ 1"].each do |input|
15
+ context input do
16
+ let!(:input) { input }
17
+
18
+ it { expect(subject.to_json).to include("cool") }
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe ::Code::Parser do
4
+ subject { ::Code::Parser.parse(input) }
5
+
6
+ [
7
+ "while false",
8
+ "while false a end",
9
+ "while false a",
10
+ "until true",
11
+ "until true a",
12
+ "until true a end"
13
+ ].each do |input|
14
+ context input do
15
+ let!(:input) { input }
16
+
17
+ it { expect { subject }.to_not raise_error }
18
+ end
19
+ end
20
+
21
+ [
22
+ "while /* cool */ a",
23
+ "while a /* cool */ b",
24
+ "until a b /* cool */ end"
25
+ ].each do |input|
26
+ context input do
27
+ let!(:input) { input }
28
+
29
+ it { expect(subject.to_json).to include("cool") }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,6 @@
1
+ require_relative "../lib/template-ruby-parser"
2
+ require "json"
3
+
4
+ RSpec.configure do |c|
5
+ c.example_status_persistence_file_path = "tmp/examples.txt"
6
+ end
@@ -0,0 +1,13 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe ::Template::Parser do
4
+ subject { ::Template::Parser.parse(input) }
5
+
6
+ ["Hello", "Hello {name}", "Hello \\{name}"].each do |input|
7
+ context input do
8
+ let!(:input) { input }
9
+
10
+ it { expect { subject }.to_not raise_error }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ require_relative "lib/template-ruby-parser"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "template-ruby-parser"
5
+ s.version = ::Template::Parser::Version
6
+ s.summary = "A parser for the Template programming language"
7
+ s.description =
8
+ 'Like "Hello {name}" with {name: "Dorian"} gives "Hello Dorian"'
9
+ s.authors = ["Dorian Marié"]
10
+ s.email = "dorian@dorianmarie.fr"
11
+ s.files = `git ls-files`.split($/)
12
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
13
+ s.require_paths = ["lib"]
14
+ s.homepage = "https://github.com/dorianmariefr/template-ruby-parser"
15
+ s.license = "MIT"
16
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: code-ruby-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dorian Marié
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-11-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A parser for the Code programming language, like 1 + 1 and user.first_name
14
+ email: dorian@dorianmarie.fr
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - ".overcommit.yml"
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - bin/code-parser
24
+ - bin/format
25
+ - bin/template-parser
26
+ - docs/class.code
27
+ - docs/meetup.code
28
+ - docs/rain.code
29
+ - docs/slack.code
30
+ - docs/stripe.code
31
+ - docs/twitter.code
32
+ - lib/code-ruby-parser.rb
33
+ - lib/code.rb
34
+ - lib/code/parser.rb
35
+ - lib/code/parser/addition.rb
36
+ - lib/code/parser/and_operator.rb
37
+ - lib/code/parser/bitwise_and.rb
38
+ - lib/code/parser/bitwise_or.rb
39
+ - lib/code/parser/boolean.rb
40
+ - lib/code/parser/call.rb
41
+ - lib/code/parser/chained_call.rb
42
+ - lib/code/parser/class.rb
43
+ - lib/code/parser/code.rb
44
+ - lib/code/parser/comments.rb
45
+ - lib/code/parser/dictionnary.rb
46
+ - lib/code/parser/equal.rb
47
+ - lib/code/parser/equality.rb
48
+ - lib/code/parser/error.rb
49
+ - lib/code/parser/error/syntax_error.rb
50
+ - lib/code/parser/function.rb
51
+ - lib/code/parser/greater_than.rb
52
+ - lib/code/parser/group.rb
53
+ - lib/code/parser/identifier.rb
54
+ - lib/code/parser/if.rb
55
+ - lib/code/parser/if_modifier.rb
56
+ - lib/code/parser/list.rb
57
+ - lib/code/parser/multiplication.rb
58
+ - lib/code/parser/negation.rb
59
+ - lib/code/parser/not_keyword.rb
60
+ - lib/code/parser/nothing.rb
61
+ - lib/code/parser/number.rb
62
+ - lib/code/parser/operation.rb
63
+ - lib/code/parser/or_keyword.rb
64
+ - lib/code/parser/or_operator.rb
65
+ - lib/code/parser/power.rb
66
+ - lib/code/parser/range.rb
67
+ - lib/code/parser/rescue.rb
68
+ - lib/code/parser/shift.rb
69
+ - lib/code/parser/statement.rb
70
+ - lib/code/parser/string.rb
71
+ - lib/code/parser/ternary.rb
72
+ - lib/code/parser/unary_minus.rb
73
+ - lib/code/parser/while.rb
74
+ - lib/template-ruby-parser.rb
75
+ - lib/template.rb
76
+ - lib/template/parser.rb
77
+ - spec/code/parser/addition_spec.rb
78
+ - spec/code/parser/and_operator_spec.rb
79
+ - spec/code/parser/bitwise_and_spec.rb
80
+ - spec/code/parser/bitwise_or_spec.rb
81
+ - spec/code/parser/boolean_spec.rb
82
+ - spec/code/parser/call_spec.rb
83
+ - spec/code/parser/chained_call_spec.rb
84
+ - spec/code/parser/class_spec.rb
85
+ - spec/code/parser/code_spec.rb
86
+ - spec/code/parser/dictionnary_spec.rb
87
+ - spec/code/parser/equal_spec.rb
88
+ - spec/code/parser/equality_spec.rb
89
+ - spec/code/parser/function_spec.rb
90
+ - spec/code/parser/greater_than_spec.rb
91
+ - spec/code/parser/group_spec.rb
92
+ - spec/code/parser/if_modifier_spec.rb
93
+ - spec/code/parser/if_spec.rb
94
+ - spec/code/parser/list_spec.rb
95
+ - spec/code/parser/multiplication_spec.rb
96
+ - spec/code/parser/negation_spec.rb
97
+ - spec/code/parser/not_keyword_spec.rb
98
+ - spec/code/parser/nothing_spec.rb
99
+ - spec/code/parser/number_spec.rb
100
+ - spec/code/parser/or_keyword_spec.rb
101
+ - spec/code/parser/or_operator_spec.rb
102
+ - spec/code/parser/power_spec.rb
103
+ - spec/code/parser/range_spec.rb
104
+ - spec/code/parser/rescue_spec.rb
105
+ - spec/code/parser/shift_spec.rb
106
+ - spec/code/parser/string_spec.rb
107
+ - spec/code/parser/ternary_spec.rb
108
+ - spec/code/parser/unary_minus_spec.rb
109
+ - spec/code/parser/while_spec.rb
110
+ - spec/spec_helper.rb
111
+ - spec/template/parser_spec.rb
112
+ - template-ruby-parser.gemspec
113
+ homepage: https://github.com/dorianmariefr/template-ruby-parser
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubygems_version: 3.3.7
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: A parser for the Code programming language
136
+ test_files:
137
+ - spec/code/parser/addition_spec.rb
138
+ - spec/code/parser/and_operator_spec.rb
139
+ - spec/code/parser/bitwise_and_spec.rb
140
+ - spec/code/parser/bitwise_or_spec.rb
141
+ - spec/code/parser/boolean_spec.rb
142
+ - spec/code/parser/call_spec.rb
143
+ - spec/code/parser/chained_call_spec.rb
144
+ - spec/code/parser/class_spec.rb
145
+ - spec/code/parser/code_spec.rb
146
+ - spec/code/parser/dictionnary_spec.rb
147
+ - spec/code/parser/equal_spec.rb
148
+ - spec/code/parser/equality_spec.rb
149
+ - spec/code/parser/function_spec.rb
150
+ - spec/code/parser/greater_than_spec.rb
151
+ - spec/code/parser/group_spec.rb
152
+ - spec/code/parser/if_modifier_spec.rb
153
+ - spec/code/parser/if_spec.rb
154
+ - spec/code/parser/list_spec.rb
155
+ - spec/code/parser/multiplication_spec.rb
156
+ - spec/code/parser/negation_spec.rb
157
+ - spec/code/parser/not_keyword_spec.rb
158
+ - spec/code/parser/nothing_spec.rb
159
+ - spec/code/parser/number_spec.rb
160
+ - spec/code/parser/or_keyword_spec.rb
161
+ - spec/code/parser/or_operator_spec.rb
162
+ - spec/code/parser/power_spec.rb
163
+ - spec/code/parser/range_spec.rb
164
+ - spec/code/parser/rescue_spec.rb
165
+ - spec/code/parser/shift_spec.rb
166
+ - spec/code/parser/string_spec.rb
167
+ - spec/code/parser/ternary_spec.rb
168
+ - spec/code/parser/unary_minus_spec.rb
169
+ - spec/code/parser/while_spec.rb
170
+ - spec/spec_helper.rb
171
+ - spec/template/parser_spec.rb