template-ruby-parser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.overcommit.yml +4 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +32 -0
- data/bin/code-parser +27 -0
- data/bin/format +3 -0
- data/bin/template-parser +27 -0
- data/docs/class.code +9 -0
- data/docs/meetup.code +14 -0
- data/docs/rain.code +23 -0
- data/docs/slack.code +17 -0
- data/docs/stripe.code +7 -0
- data/docs/twitter.code +7 -0
- data/lib/code/parser/addition.rb +13 -0
- data/lib/code/parser/and_operator.rb +13 -0
- data/lib/code/parser/bitwise_and.rb +13 -0
- data/lib/code/parser/bitwise_or.rb +13 -0
- data/lib/code/parser/boolean.rb +13 -0
- data/lib/code/parser/call.rb +174 -0
- data/lib/code/parser/chained_call.rb +41 -0
- data/lib/code/parser/class.rb +56 -0
- data/lib/code/parser/code.rb +20 -0
- data/lib/code/parser/comments.rb +46 -0
- data/lib/code/parser/dictionnary.rb +48 -0
- data/lib/code/parser/equal.rb +39 -0
- data/lib/code/parser/equality.rb +20 -0
- data/lib/code/parser/error/syntax_error.rb +36 -0
- data/lib/code/parser/error.rb +6 -0
- data/lib/code/parser/function.rb +109 -0
- data/lib/code/parser/greater_than.rb +13 -0
- data/lib/code/parser/group.rb +15 -0
- data/lib/code/parser/identifier.rb +54 -0
- data/lib/code/parser/if.rb +81 -0
- data/lib/code/parser/if_modifier.rb +39 -0
- data/lib/code/parser/list.rb +20 -0
- data/lib/code/parser/multiplication.rb +13 -0
- data/lib/code/parser/negation.rb +18 -0
- data/lib/code/parser/not_keyword.rb +24 -0
- data/lib/code/parser/nothing.rb +13 -0
- data/lib/code/parser/number.rb +39 -0
- data/lib/code/parser/operation.rb +44 -0
- data/lib/code/parser/or_keyword.rb +13 -0
- data/lib/code/parser/or_operator.rb +13 -0
- data/lib/code/parser/power.rb +33 -0
- data/lib/code/parser/range.rb +13 -0
- data/lib/code/parser/rescue.rb +38 -0
- data/lib/code/parser/shift.rb +13 -0
- data/lib/code/parser/statement.rb +9 -0
- data/lib/code/parser/string.rb +61 -0
- data/lib/code/parser/ternary.rb +73 -0
- data/lib/code/parser/unary_minus.rb +23 -0
- data/lib/code/parser/while.rb +36 -0
- data/lib/code/parser.rb +237 -0
- data/lib/code-ruby-parser.rb +7 -0
- data/lib/code.rb +2 -0
- data/lib/template/parser.rb +32 -0
- data/lib/template-ruby-parser.rb +7 -0
- data/lib/template.rb +2 -0
- data/spec/code/parser/addition_spec.rb +26 -0
- data/spec/code/parser/and_operator_spec.rb +26 -0
- data/spec/code/parser/bitwise_and_spec.rb +26 -0
- data/spec/code/parser/bitwise_or_spec.rb +26 -0
- data/spec/code/parser/boolean_spec.rb +13 -0
- data/spec/code/parser/call_spec.rb +52 -0
- data/spec/code/parser/chained_call_spec.rb +33 -0
- data/spec/code/parser/class_spec.rb +32 -0
- data/spec/code/parser/code_spec.rb +13 -0
- data/spec/code/parser/dictionnary_spec.rb +40 -0
- data/spec/code/parser/equal_spec.rb +42 -0
- data/spec/code/parser/equality_spec.rb +26 -0
- data/spec/code/parser/function_spec.rb +43 -0
- data/spec/code/parser/greater_than_spec.rb +26 -0
- data/spec/code/parser/group_spec.rb +13 -0
- data/spec/code/parser/if_modifier_spec.rb +26 -0
- data/spec/code/parser/if_spec.rb +39 -0
- data/spec/code/parser/list_spec.rb +27 -0
- data/spec/code/parser/multiplication_spec.rb +26 -0
- data/spec/code/parser/negation_spec.rb +13 -0
- data/spec/code/parser/not_keyword_spec.rb +21 -0
- data/spec/code/parser/nothing_spec.rb +20 -0
- data/spec/code/parser/number_spec.rb +24 -0
- data/spec/code/parser/or_keyword_spec.rb +26 -0
- data/spec/code/parser/or_operator_spec.rb +26 -0
- data/spec/code/parser/power_spec.rb +21 -0
- data/spec/code/parser/range_spec.rb +21 -0
- data/spec/code/parser/rescue_spec.rb +26 -0
- data/spec/code/parser/shift_spec.rb +26 -0
- data/spec/code/parser/string_spec.rb +27 -0
- data/spec/code/parser/ternary_spec.rb +26 -0
- data/spec/code/parser/unary_minus_spec.rb +21 -0
- data/spec/code/parser/while_spec.rb +32 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/template/parser_spec.rb +13 -0
- data/template-ruby-parser.gemspec +16 -0
- 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
|
data/spec/spec_helper.rb
ADDED
@@ -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: template-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: 'Like "Hello {name}" with {name: "Dorian"} gives "Hello Dorian"'
|
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 Template 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
|