language-ruby 0.5.6 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.ruby-version +1 -0
  4. data/.tool-versions +1 -1
  5. data/Gemfile +5 -4
  6. data/Gemfile.lock +12 -23
  7. data/README.md +2 -102
  8. data/language-ruby.gemspec +7 -5
  9. data/lib/language/atom/absent.rb +29 -0
  10. data/lib/language/atom/aka.rb +32 -0
  11. data/lib/language/atom/and.rb +32 -0
  12. data/lib/language/atom/any.rb +15 -0
  13. data/lib/language/atom/ignore.rb +27 -0
  14. data/lib/language/atom/maybe.rb +32 -0
  15. data/lib/language/atom/or.rb +46 -0
  16. data/lib/language/atom/repeat.rb +57 -0
  17. data/lib/language/atom/str.rb +21 -0
  18. data/lib/language/atom/then.rb +21 -0
  19. data/lib/language/atom.rb +10 -291
  20. data/lib/language/output.rb +13 -11
  21. data/lib/language/parser/absent/present.rb +2 -0
  22. data/lib/language/parser/absent.rb +2 -0
  23. data/lib/language/parser/end_of_input.rb +2 -0
  24. data/lib/language/parser/interuption.rb +2 -0
  25. data/lib/language/parser/not_end_of_input.rb +2 -0
  26. data/lib/language/parser/str/not_found.rb +2 -0
  27. data/lib/language/parser/str.rb +2 -0
  28. data/lib/language/parser.rb +10 -10
  29. data/lib/language/version.rb +5 -0
  30. data/lib/language-ruby.rb +2 -5
  31. data/lib/language.rb +9 -7
  32. data/spec/language_spec.rb +21 -0
  33. data/spec/spec_helper.rb +2 -5
  34. metadata +18 -218
  35. data/.cherry.js +0 -21
  36. data/.editorconfig +0 -9
  37. data/.github/workflows/rspec.yml +0 -14
  38. data/.prettierrc +0 -3
  39. data/CHANGELOG.md +0 -55
  40. data/LICENSE +0 -7
  41. data/TODO +0 -17
  42. data/bin/code +0 -76
  43. data/bin/format +0 -3
  44. data/bin/publish +0 -19
  45. data/bin/template +0 -85
  46. data/bin/test +0 -17
  47. data/code-ruby.gemspec +0 -17
  48. data/docs/class.code +0 -9
  49. data/docs/euler/1.template +0 -10
  50. data/docs/euler/2.template +0 -16
  51. data/docs/euler/3.template +0 -16
  52. data/docs/euler/4.template +0 -10
  53. data/docs/euler/5.template +0 -13
  54. data/docs/fibonnaci.template +0 -14
  55. data/docs/meetup.code +0 -12
  56. data/docs/precedence.template +0 -36
  57. data/docs/rain.code +0 -22
  58. data/docs/slack.code +0 -17
  59. data/docs/stripe.code +0 -7
  60. data/docs/twitter.code +0 -9
  61. data/lib/code/error.rb +0 -18
  62. data/lib/code/node/base_10.rb +0 -29
  63. data/lib/code/node/base_16.rb +0 -13
  64. data/lib/code/node/base_2.rb +0 -13
  65. data/lib/code/node/base_8.rb +0 -13
  66. data/lib/code/node/boolean.rb +0 -22
  67. data/lib/code/node/call.rb +0 -47
  68. data/lib/code/node/call_argument.rb +0 -21
  69. data/lib/code/node/chained_call.rb +0 -23
  70. data/lib/code/node/code.rb +0 -20
  71. data/lib/code/node/decimal.rb +0 -26
  72. data/lib/code/node/dictionnary.rb +0 -33
  73. data/lib/code/node/equal.rb +0 -34
  74. data/lib/code/node/function.rb +0 -20
  75. data/lib/code/node/function_parameter.rb +0 -31
  76. data/lib/code/node/if.rb +0 -59
  77. data/lib/code/node/if_modifier.rb +0 -47
  78. data/lib/code/node/list.rb +0 -16
  79. data/lib/code/node/negation.rb +0 -15
  80. data/lib/code/node/not.rb +0 -15
  81. data/lib/code/node/nothing.rb +0 -12
  82. data/lib/code/node/number.rb +0 -25
  83. data/lib/code/node/operation.rb +0 -38
  84. data/lib/code/node/power.rb +0 -20
  85. data/lib/code/node/rescue.rb +0 -17
  86. data/lib/code/node/splat.rb +0 -15
  87. data/lib/code/node/statement.rb +0 -59
  88. data/lib/code/node/string.rb +0 -53
  89. data/lib/code/node/ternary.rb +0 -24
  90. data/lib/code/node/unary_minus.rb +0 -15
  91. data/lib/code/node/while.rb +0 -35
  92. data/lib/code/node.rb +0 -13
  93. data/lib/code/object/argument.rb +0 -32
  94. data/lib/code/object/boolean.rb +0 -27
  95. data/lib/code/object/decimal.rb +0 -162
  96. data/lib/code/object/dictionnary.rb +0 -96
  97. data/lib/code/object/function.rb +0 -64
  98. data/lib/code/object/global.rb +0 -42
  99. data/lib/code/object/integer.rb +0 -221
  100. data/lib/code/object/list.rb +0 -207
  101. data/lib/code/object/nothing.rb +0 -23
  102. data/lib/code/object/number.rb +0 -6
  103. data/lib/code/object/range.rb +0 -146
  104. data/lib/code/object/ruby_function.rb +0 -31
  105. data/lib/code/object/string.rb +0 -102
  106. data/lib/code/object.rb +0 -197
  107. data/lib/code/parser/addition.rb +0 -21
  108. data/lib/code/parser/and_operator.rb +0 -17
  109. data/lib/code/parser/bitwise_and.rb +0 -17
  110. data/lib/code/parser/bitwise_or.rb +0 -21
  111. data/lib/code/parser/boolean.rb +0 -17
  112. data/lib/code/parser/call.rb +0 -122
  113. data/lib/code/parser/chained_call.rb +0 -47
  114. data/lib/code/parser/class.rb +0 -45
  115. data/lib/code/parser/code.rb +0 -25
  116. data/lib/code/parser/dictionnary.rb +0 -67
  117. data/lib/code/parser/equal.rb +0 -94
  118. data/lib/code/parser/equality.rb +0 -35
  119. data/lib/code/parser/equality_lower.rb +0 -9
  120. data/lib/code/parser/function.rb +0 -85
  121. data/lib/code/parser/greater.rb +0 -25
  122. data/lib/code/parser/group.rb +0 -22
  123. data/lib/code/parser/if.rb +0 -63
  124. data/lib/code/parser/if_modifier.rb +0 -55
  125. data/lib/code/parser/list.rb +0 -42
  126. data/lib/code/parser/multiplication.rb +0 -25
  127. data/lib/code/parser/name.rb +0 -107
  128. data/lib/code/parser/negation.rb +0 -30
  129. data/lib/code/parser/not_keyword.rb +0 -23
  130. data/lib/code/parser/nothing.rb +0 -22
  131. data/lib/code/parser/number.rb +0 -154
  132. data/lib/code/parser/operation.rb +0 -35
  133. data/lib/code/parser/or_keyword.rb +0 -21
  134. data/lib/code/parser/or_operator.rb +0 -17
  135. data/lib/code/parser/power.rb +0 -43
  136. data/lib/code/parser/range.rb +0 -17
  137. data/lib/code/parser/rescue.rb +0 -39
  138. data/lib/code/parser/shift.rb +0 -21
  139. data/lib/code/parser/splat.rb +0 -31
  140. data/lib/code/parser/statement.rb +0 -9
  141. data/lib/code/parser/string.rb +0 -78
  142. data/lib/code/parser/ternary.rb +0 -46
  143. data/lib/code/parser/unary_minus.rb +0 -31
  144. data/lib/code/parser/while.rb +0 -36
  145. data/lib/code/parser/whitespace.rb +0 -49
  146. data/lib/code/parser.rb +0 -19
  147. data/lib/code/ruby.rb +0 -174
  148. data/lib/code-ruby.rb +0 -10
  149. data/lib/code.rb +0 -47
  150. data/lib/template/node/code_part.rb +0 -13
  151. data/lib/template/node/part.rb +0 -19
  152. data/lib/template/node/template.rb +0 -15
  153. data/lib/template/node/text_part.rb +0 -13
  154. data/lib/template/node.rb +0 -4
  155. data/lib/template/parser/template.rb +0 -39
  156. data/lib/template/parser.rb +0 -19
  157. data/lib/template/version.rb +0 -3
  158. data/lib/template-ruby.rb +0 -10
  159. data/lib/template.rb +0 -50
  160. data/spec/code/addition_spec.rb +0 -13
  161. data/spec/code/and_operator_spec.rb +0 -13
  162. data/spec/code/bitwise_and_spec.rb +0 -13
  163. data/spec/code/bitwise_or_spec.rb +0 -13
  164. data/spec/code/boolean_spec.rb +0 -13
  165. data/spec/code/call_spec.rb +0 -21
  166. data/spec/code/chained_call_spec.rb +0 -16
  167. data/spec/code/code_spec.rb +0 -29
  168. data/spec/code/dictionnary_spec.rb +0 -17
  169. data/spec/code/equal_spec.rb +0 -26
  170. data/spec/code/equality_spec.rb +0 -13
  171. data/spec/code/function_spec.rb +0 -18
  172. data/spec/code/greater_spec.rb +0 -18
  173. data/spec/code/group_spec.rb +0 -12
  174. data/spec/code/if_modifier_spec.rb +0 -20
  175. data/spec/code/if_spec.rb +0 -25
  176. data/spec/code/list_spec.rb +0 -19
  177. data/spec/code/multiplication_spec.rb +0 -18
  178. data/spec/code/negation_spec.rb +0 -20
  179. data/spec/code/not_keyword_spec.rb +0 -13
  180. data/spec/code/nothing_spec.rb +0 -17
  181. data/spec/code/number_spec.rb +0 -22
  182. data/spec/code/or_keyword_spec.rb +0 -17
  183. data/spec/code/or_operator_spec.rb +0 -16
  184. data/spec/code/parser/boolean_spec.rb +0 -16
  185. data/spec/code/parser/call_spec.rb +0 -26
  186. data/spec/code/parser/chained_call.rb +0 -17
  187. data/spec/code/parser/dictionnary_spec.rb +0 -18
  188. data/spec/code/parser/function_spec.rb +0 -16
  189. data/spec/code/parser/group_spec.rb +0 -18
  190. data/spec/code/parser/list_spec.rb +0 -18
  191. data/spec/code/parser/number_spec.rb +0 -12
  192. data/spec/code/parser/string_spec.rb +0 -21
  193. data/spec/code/parser_spec.rb +0 -23
  194. data/spec/code/power_spec.rb +0 -13
  195. data/spec/code/range_spec.rb +0 -16
  196. data/spec/code/rescue_spec.rb +0 -13
  197. data/spec/code/shift_spec.rb +0 -13
  198. data/spec/code/splat_spec.rb +0 -13
  199. data/spec/code/string_spec.rb +0 -27
  200. data/spec/code/ternary_spec.rb +0 -18
  201. data/spec/code/unary_minus_spec.rb +0 -13
  202. data/spec/code/while_spec.rb +0 -18
  203. data/template-ruby.gemspec +0 -19
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: language-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-18 00:00:00.000000000 Z
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -30,131 +30,27 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
- - ".cherry.js"
34
- - ".editorconfig"
35
- - ".github/workflows/rspec.yml"
36
33
  - ".gitignore"
37
- - ".prettierrc"
38
34
  - ".rspec"
35
+ - ".ruby-version"
39
36
  - ".tool-versions"
40
- - CHANGELOG.md
41
37
  - Gemfile
42
38
  - Gemfile.lock
43
- - LICENSE
44
39
  - README.md
45
- - TODO
46
- - bin/code
47
- - bin/format
48
- - bin/publish
49
- - bin/template
50
- - bin/test
51
- - code-ruby.gemspec
52
- - docs/class.code
53
- - docs/euler/1.template
54
- - docs/euler/2.template
55
- - docs/euler/3.template
56
- - docs/euler/4.template
57
- - docs/euler/5.template
58
- - docs/fibonnaci.template
59
- - docs/meetup.code
60
- - docs/precedence.template
61
- - docs/rain.code
62
- - docs/slack.code
63
- - docs/stripe.code
64
- - docs/twitter.code
65
40
  - language-ruby.gemspec
66
- - lib/code-ruby.rb
67
- - lib/code.rb
68
- - lib/code/error.rb
69
- - lib/code/node.rb
70
- - lib/code/node/base_10.rb
71
- - lib/code/node/base_16.rb
72
- - lib/code/node/base_2.rb
73
- - lib/code/node/base_8.rb
74
- - lib/code/node/boolean.rb
75
- - lib/code/node/call.rb
76
- - lib/code/node/call_argument.rb
77
- - lib/code/node/chained_call.rb
78
- - lib/code/node/code.rb
79
- - lib/code/node/decimal.rb
80
- - lib/code/node/dictionnary.rb
81
- - lib/code/node/equal.rb
82
- - lib/code/node/function.rb
83
- - lib/code/node/function_parameter.rb
84
- - lib/code/node/if.rb
85
- - lib/code/node/if_modifier.rb
86
- - lib/code/node/list.rb
87
- - lib/code/node/negation.rb
88
- - lib/code/node/not.rb
89
- - lib/code/node/nothing.rb
90
- - lib/code/node/number.rb
91
- - lib/code/node/operation.rb
92
- - lib/code/node/power.rb
93
- - lib/code/node/rescue.rb
94
- - lib/code/node/splat.rb
95
- - lib/code/node/statement.rb
96
- - lib/code/node/string.rb
97
- - lib/code/node/ternary.rb
98
- - lib/code/node/unary_minus.rb
99
- - lib/code/node/while.rb
100
- - lib/code/object.rb
101
- - lib/code/object/argument.rb
102
- - lib/code/object/boolean.rb
103
- - lib/code/object/decimal.rb
104
- - lib/code/object/dictionnary.rb
105
- - lib/code/object/function.rb
106
- - lib/code/object/global.rb
107
- - lib/code/object/integer.rb
108
- - lib/code/object/list.rb
109
- - lib/code/object/nothing.rb
110
- - lib/code/object/number.rb
111
- - lib/code/object/range.rb
112
- - lib/code/object/ruby_function.rb
113
- - lib/code/object/string.rb
114
- - lib/code/parser.rb
115
- - lib/code/parser/addition.rb
116
- - lib/code/parser/and_operator.rb
117
- - lib/code/parser/bitwise_and.rb
118
- - lib/code/parser/bitwise_or.rb
119
- - lib/code/parser/boolean.rb
120
- - lib/code/parser/call.rb
121
- - lib/code/parser/chained_call.rb
122
- - lib/code/parser/class.rb
123
- - lib/code/parser/code.rb
124
- - lib/code/parser/dictionnary.rb
125
- - lib/code/parser/equal.rb
126
- - lib/code/parser/equality.rb
127
- - lib/code/parser/equality_lower.rb
128
- - lib/code/parser/function.rb
129
- - lib/code/parser/greater.rb
130
- - lib/code/parser/group.rb
131
- - lib/code/parser/if.rb
132
- - lib/code/parser/if_modifier.rb
133
- - lib/code/parser/list.rb
134
- - lib/code/parser/multiplication.rb
135
- - lib/code/parser/name.rb
136
- - lib/code/parser/negation.rb
137
- - lib/code/parser/not_keyword.rb
138
- - lib/code/parser/nothing.rb
139
- - lib/code/parser/number.rb
140
- - lib/code/parser/operation.rb
141
- - lib/code/parser/or_keyword.rb
142
- - lib/code/parser/or_operator.rb
143
- - lib/code/parser/power.rb
144
- - lib/code/parser/range.rb
145
- - lib/code/parser/rescue.rb
146
- - lib/code/parser/shift.rb
147
- - lib/code/parser/splat.rb
148
- - lib/code/parser/statement.rb
149
- - lib/code/parser/string.rb
150
- - lib/code/parser/ternary.rb
151
- - lib/code/parser/unary_minus.rb
152
- - lib/code/parser/while.rb
153
- - lib/code/parser/whitespace.rb
154
- - lib/code/ruby.rb
155
41
  - lib/language-ruby.rb
156
42
  - lib/language.rb
157
43
  - lib/language/atom.rb
44
+ - lib/language/atom/absent.rb
45
+ - lib/language/atom/aka.rb
46
+ - lib/language/atom/and.rb
47
+ - lib/language/atom/any.rb
48
+ - lib/language/atom/ignore.rb
49
+ - lib/language/atom/maybe.rb
50
+ - lib/language/atom/or.rb
51
+ - lib/language/atom/repeat.rb
52
+ - lib/language/atom/str.rb
53
+ - lib/language/atom/then.rb
158
54
  - lib/language/output.rb
159
55
  - lib/language/parser.rb
160
56
  - lib/language/parser/absent.rb
@@ -164,62 +60,10 @@ files:
164
60
  - lib/language/parser/not_end_of_input.rb
165
61
  - lib/language/parser/str.rb
166
62
  - lib/language/parser/str/not_found.rb
167
- - lib/template-ruby.rb
168
- - lib/template.rb
169
- - lib/template/node.rb
170
- - lib/template/node/code_part.rb
171
- - lib/template/node/part.rb
172
- - lib/template/node/template.rb
173
- - lib/template/node/text_part.rb
174
- - lib/template/parser.rb
175
- - lib/template/parser/template.rb
176
- - lib/template/version.rb
177
- - spec/code/addition_spec.rb
178
- - spec/code/and_operator_spec.rb
179
- - spec/code/bitwise_and_spec.rb
180
- - spec/code/bitwise_or_spec.rb
181
- - spec/code/boolean_spec.rb
182
- - spec/code/call_spec.rb
183
- - spec/code/chained_call_spec.rb
184
- - spec/code/code_spec.rb
185
- - spec/code/dictionnary_spec.rb
186
- - spec/code/equal_spec.rb
187
- - spec/code/equality_spec.rb
188
- - spec/code/function_spec.rb
189
- - spec/code/greater_spec.rb
190
- - spec/code/group_spec.rb
191
- - spec/code/if_modifier_spec.rb
192
- - spec/code/if_spec.rb
193
- - spec/code/list_spec.rb
194
- - spec/code/multiplication_spec.rb
195
- - spec/code/negation_spec.rb
196
- - spec/code/not_keyword_spec.rb
197
- - spec/code/nothing_spec.rb
198
- - spec/code/number_spec.rb
199
- - spec/code/or_keyword_spec.rb
200
- - spec/code/or_operator_spec.rb
201
- - spec/code/parser/boolean_spec.rb
202
- - spec/code/parser/call_spec.rb
203
- - spec/code/parser/chained_call.rb
204
- - spec/code/parser/dictionnary_spec.rb
205
- - spec/code/parser/function_spec.rb
206
- - spec/code/parser/group_spec.rb
207
- - spec/code/parser/list_spec.rb
208
- - spec/code/parser/number_spec.rb
209
- - spec/code/parser/string_spec.rb
210
- - spec/code/parser_spec.rb
211
- - spec/code/power_spec.rb
212
- - spec/code/range_spec.rb
213
- - spec/code/rescue_spec.rb
214
- - spec/code/shift_spec.rb
215
- - spec/code/splat_spec.rb
216
- - spec/code/string_spec.rb
217
- - spec/code/ternary_spec.rb
218
- - spec/code/unary_minus_spec.rb
219
- - spec/code/while_spec.rb
63
+ - lib/language/version.rb
64
+ - spec/language_spec.rb
220
65
  - spec/spec_helper.rb
221
- - template-ruby.gemspec
222
- homepage: https://github.com/dorianmariefr/template-ruby
66
+ homepage: https://github.com/dorianmariefr/language-ruby
223
67
  licenses:
224
68
  - MIT
225
69
  metadata: {}
@@ -238,52 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
82
  - !ruby/object:Gem::Version
239
83
  version: '0'
240
84
  requirements: []
241
- rubygems_version: 3.3.26
85
+ rubygems_version: 3.5.3
242
86
  signing_key:
243
87
  specification_version: 4
244
88
  summary: A Parsing Expression Grammar (PEG) for making parsers
245
- test_files:
246
- - spec/code/addition_spec.rb
247
- - spec/code/and_operator_spec.rb
248
- - spec/code/bitwise_and_spec.rb
249
- - spec/code/bitwise_or_spec.rb
250
- - spec/code/boolean_spec.rb
251
- - spec/code/call_spec.rb
252
- - spec/code/chained_call_spec.rb
253
- - spec/code/code_spec.rb
254
- - spec/code/dictionnary_spec.rb
255
- - spec/code/equal_spec.rb
256
- - spec/code/equality_spec.rb
257
- - spec/code/function_spec.rb
258
- - spec/code/greater_spec.rb
259
- - spec/code/group_spec.rb
260
- - spec/code/if_modifier_spec.rb
261
- - spec/code/if_spec.rb
262
- - spec/code/list_spec.rb
263
- - spec/code/multiplication_spec.rb
264
- - spec/code/negation_spec.rb
265
- - spec/code/not_keyword_spec.rb
266
- - spec/code/nothing_spec.rb
267
- - spec/code/number_spec.rb
268
- - spec/code/or_keyword_spec.rb
269
- - spec/code/or_operator_spec.rb
270
- - spec/code/parser/boolean_spec.rb
271
- - spec/code/parser/call_spec.rb
272
- - spec/code/parser/chained_call.rb
273
- - spec/code/parser/dictionnary_spec.rb
274
- - spec/code/parser/function_spec.rb
275
- - spec/code/parser/group_spec.rb
276
- - spec/code/parser/list_spec.rb
277
- - spec/code/parser/number_spec.rb
278
- - spec/code/parser/string_spec.rb
279
- - spec/code/parser_spec.rb
280
- - spec/code/power_spec.rb
281
- - spec/code/range_spec.rb
282
- - spec/code/rescue_spec.rb
283
- - spec/code/shift_spec.rb
284
- - spec/code/splat_spec.rb
285
- - spec/code/string_spec.rb
286
- - spec/code/ternary_spec.rb
287
- - spec/code/unary_minus_spec.rb
288
- - spec/code/while_spec.rb
289
- - spec/spec_helper.rb
89
+ test_files: []
data/.cherry.js DELETED
@@ -1,21 +0,0 @@
1
- module.exports = {
2
- project_name: 'dorianmariefr/template-ruby',
3
- metrics: [
4
- {
5
- name: 'todo',
6
- pattern: /TODO:/i,
7
- },
8
- {
9
- name: 'fixme',
10
- pattern: /FIXME:/i,
11
- },
12
- {
13
- name: 'rubocop',
14
- pattern: /rubocop:disable/,
15
- },
16
- {
17
- name: 'eslint',
18
- pattern: /eslint-disable/,
19
- },
20
- ],
21
- }
data/.editorconfig DELETED
@@ -1,9 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- end_of_line = lf
6
- insert_final_newline = true
7
- indent_style = space
8
- indent_size = 2
9
- trim_trailing_whitespace = true
@@ -1,14 +0,0 @@
1
- name: RSpec
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- name: RSpec
8
- runs-on: ubuntu-latest
9
-
10
- steps:
11
- - uses: actions/checkout@v1
12
- - uses: actions/setup-ruby@v1
13
- - run: bundle install
14
- - run: bundle exec rspec
data/.prettierrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "rubyPlugins": "plugin/trailing_comma"
3
- }
data/CHANGELOG.md DELETED
@@ -1,55 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## 0.4.0 / 2022-10-21
9
-
10
- - Rewrite of how functions are called internally (no more `public_send`)
11
- - Call ruby functions from template/code
12
-
13
- ## 0.3.1 / 2022-10-13
14
-
15
- - Fix Zeitwerk auto-loading issue
16
-
17
- ## 0.3.0 / 2022-10-10
18
-
19
- - `bin/template` accepts `--timeout` (or `-t`) parameter
20
- - Adds `bin/code` with same options as `bin/template`
21
- - Prevent loose syntax like `{ a: }`, `[1,,,]` and `()`
22
- - Change precedence of defined? (to allow `defined?(name) ? name : nothing`)
23
- - Updates parsers to allow `while false end == nothing`
24
- - String interpolations like `"1 + 1 = {1 + 1}"`
25
- - `context(:name)` to get a function without calling it for instance
26
- - `.to_string` on all objects
27
- - `1 + "a"` and `"a" + 1.0` for instance now convert to strings
28
- - `Dictionnary#each` e.g. `{ a: 1 }.each { |k, v| print(k) }`
29
- - Fix context duplication issue that was preventing implementation of recursive
30
- functions like Fibonacci
31
-
32
- ## 0.2.4 / 2022-08-02
33
-
34
- - Add method `String#*`, e.g. `{"Dorian " \* 2}" -> "Dorian Dorian "
35
- - Add executable to gem, e.g. `template --help`
36
-
37
- ## 0.2.3 / 2022-08-31
38
-
39
- - Add default timeout for code and template parsing and evaluation
40
-
41
- ## 0.2.2 / 2022-08-31
42
-
43
- - Fix parsing error when the template is empty, e.g. ""
44
-
45
- ## 0.2.1 / 2022-08-31
46
-
47
- - Fix parsing error on empty code like `Hello {`
48
-
49
- ## 0.2.0 / 2022-08-30
50
-
51
- - Programming language capable of solving the first 5 Project Euler problems
52
-
53
- ## 0.1.0 / 2022-07-28
54
-
55
- - Initial version with interpolation
data/LICENSE DELETED
@@ -1,7 +0,0 @@
1
- Copyright 2022 Dorian Marié <dorian@dorianmarie.fr>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/TODO DELETED
@@ -1,17 +0,0 @@
1
- - Class
2
- - Function parameters regular splat *args
3
- - Function parameters keyword splat **kargs
4
- - Function parameters block &block
5
- - Block parameters regular splat *args
6
- - Block parameters keyword splat **kargs
7
- - Block parameters block &block
8
- - Dictionnary regular splat { *args }
9
- - Dictionnary keyword splat { **kargs }
10
- - Dictionnary block { &block }
11
- - Dictionnary expand name { user } and { user: }
12
- - Rescue with exception name, rescue Code::Undefined
13
- - Rescue with exception catched, rescue => e
14
- - begin end
15
- - begin rescue end
16
- - begin rescue ensure end
17
- - begin rescue else end
data/bin/code DELETED
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "optparse"
4
- require_relative "../lib/template-ruby"
5
-
6
- options = { timeout: 0, profile: false }
7
-
8
- OptionParser
9
- .new do |opts|
10
- opts.banner = "Usage: bin/code [options]"
11
-
12
- opts.on(
13
- "-i INPUT",
14
- "--input=INPUT",
15
- "Input in the code language (String or File)"
16
- ) do |input|
17
- input = File.read(input) if File.exists?(input)
18
-
19
- options[:input] = input
20
- end
21
-
22
- opts.on(
23
- "-c CONTEXT",
24
- "--context=CONTEXT",
25
- "Context in the code language (String or File)"
26
- ) do |context|
27
- context = File.read(context) if File.exists?(context)
28
-
29
- options[:context] = context
30
- end
31
-
32
- opts.on("-p", "--parse", "Get parser results for input") do |parse|
33
- options[:parse] = parse
34
- end
35
-
36
- opts.on(
37
- "-t TIMEOUT",
38
- "--timeout=TIMEOUT",
39
- "Set timeout in seconds"
40
- ) { |timeout| options[:timeout] = timeout.to_f }
41
-
42
- opts.on(
43
- "--profile",
44
- "Profile Ruby code"
45
- ) do |timeout|
46
- require "ruby-prof"
47
- options[:profile] = true
48
- end
49
- end
50
- .parse!
51
-
52
- input = options.fetch(:input, "")
53
- context = options.fetch(:context, "")
54
-
55
- if options[:profile]
56
- RubyProf.start
57
- end
58
-
59
- if options[:parse]
60
- pp ::Code::Parser.parse(input).to_raw
61
- else
62
- print(
63
- Code.evaluate(
64
- input,
65
- context,
66
- io: $stdout,
67
- timeout: options[:timeout]
68
- ).to_s
69
- )
70
- end
71
-
72
- if options[:profile]
73
- result = RubyProf.stop
74
- printer = RubyProf::FlatPrinter.new(result)
75
- printer.print($stdout)
76
- end
data/bin/format DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env fish
2
-
3
- stree write Gemfile lib/**/*.rb spec/**/*.rb bin/code-parser
data/bin/publish DELETED
@@ -1,19 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- rm -f *.gem
6
- git pull
7
- git push
8
-
9
- for file in *.gemspec
10
- do
11
- gem build $file
12
- done
13
-
14
- for file in *.gem
15
- do
16
- gem push $file
17
- done
18
-
19
- rm *.gem
data/bin/template DELETED
@@ -1,85 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "optparse"
4
- require_relative "../lib/template-ruby"
5
-
6
- options = { timeout: 0, profile: false, profiler: "text" }
7
-
8
- OptionParser
9
- .new do |opts|
10
- opts.banner = "Usage: template [options]"
11
-
12
- opts.on(
13
- "-i INPUT",
14
- "--input=INPUT",
15
- "Input in the template language (String or File)"
16
- ) do |input|
17
- input = File.read(input) if File.exists?(input)
18
-
19
- options[:input] = input
20
- end
21
-
22
- opts.on(
23
- "-c CONTEXT",
24
- "--context=CONTEXT",
25
- "Context in the code language (String or File)"
26
- ) do |context|
27
- context = File.read(context) if File.exists?(context)
28
-
29
- options[:context] = context
30
- end
31
-
32
- opts.on("-p", "--parse", "Get parser results for input") do |parse|
33
- options[:parse] = parse
34
- end
35
-
36
- opts.on(
37
- "-t TIMEOUT",
38
- "--timeout=TIMEOUT",
39
- "Set timeout in seconds"
40
- ) { |timeout| options[:timeout] = timeout.to_f }
41
-
42
- opts.on(
43
- "--profile",
44
- "Profile Ruby code"
45
- ) do |timeout|
46
- require "ruby-prof"
47
- options[:profile] = true
48
- end
49
-
50
- opts.on(
51
- "--profiler TYPE",
52
- "Profiler output type (text (default) or html)"
53
- ) do |profiler|
54
- require "ruby-prof"
55
- options[:profile] = true
56
- options[:profiler] = profiler
57
- end
58
- end
59
- .parse!
60
-
61
- input = options.fetch(:input, "")
62
- context = options.fetch(:context, "")
63
-
64
- if options[:profile]
65
- RubyProf.start
66
- end
67
-
68
- if options[:parse]
69
- pp ::Template::Parser.parse(input).to_raw
70
- else
71
- Template.render(input, context, io: $stdout, timeout: options[:timeout])
72
- end
73
-
74
- if options[:profile]
75
- result = RubyProf.stop
76
- if options[:profiler] == "text"
77
- printer = RubyProf::FlatPrinter.new(result)
78
- printer.print($stdout)
79
- elsif options[:profiler] == "html"
80
- printer = RubyProf::GraphHtmlPrinter.new(result)
81
- printer.print($stdout)
82
- else
83
- abort "#{options[:profiler]} not recognized"
84
- end
85
- end
data/bin/test DELETED
@@ -1,17 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- rspec
6
-
7
- for f in docs/**/*.template
8
- do
9
- echo $f
10
- bin/template -i $f -p > /dev/null
11
- done
12
-
13
- for f in docs/*.code
14
- do
15
- echo $f
16
- bin/code -i $f -p > /dev/null
17
- done
data/code-ruby.gemspec DELETED
@@ -1,17 +0,0 @@
1
- require_relative "lib/template/version"
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "code-ruby"
5
- s.version = ::Template::Version
6
- s.summary = "A programming language"
7
- s.description = 'A programming language, like Code.evaluate("1 + 1") # => 2'
8
- s.authors = ["Dorian Marié"]
9
- s.email = "dorian@dorianmarie.fr"
10
- s.files = `git ls-files`.split($/)
11
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
12
- s.require_paths = ["lib"]
13
- s.homepage = "https://github.com/dorianmariefr/template-ruby"
14
- s.license = "MIT"
15
-
16
- s.add_dependency "zeitwerk", "~> 2"
17
- end
data/docs/class.code DELETED
@@ -1,9 +0,0 @@
1
- class ApiClient
2
- get = (url) => {
3
- fetch(url)
4
- }
5
- end
6
-
7
- class Twitter < ApiClient
8
- self.base_url = "https://api.twitter.com"
9
- end
@@ -1,10 +0,0 @@
1
- {
2
- sum = 0
3
-
4
- 1000.times do |i|
5
- if i % 3 == 0 or i % 5 == 0
6
- sum += i
7
- end
8
- end
9
-
10
- sum
@@ -1,16 +0,0 @@
1
- {
2
- a = 1
3
- b = 2
4
- sum = 2
5
-
6
- while b < 4000000
7
- c = a + b
8
- a = b
9
- b = c
10
-
11
- if b % 2 == 0
12
- sum += b
13
- end
14
- end
15
-
16
- sum
@@ -1,16 +0,0 @@
1
- {
2
- n = 600851475143
3
- max = 0
4
-
5
- i = 2
6
-
7
- until n == 1
8
- while n % i == 0
9
- max = i
10
- n = n / i
11
- end
12
-
13
- i += 1
14
- end
15
-
16
- max