yaparc 0.2.3 → 0.3.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.
- checksums.yaml +7 -0
- data/.document +3 -0
- data/.rdoc_options +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README +105 -85
- data/Rakefile +21 -0
- data/lib/yaparc.rb +7 -2
- data/manifest.scm +1 -0
- data/sig/yaparc.gen.rbs +220 -0
- data/sig/yaparc.rbs +4 -0
- data/yaparc.gemspec +36 -0
- metadata +91 -58
- data/test/n3-report.html +0 -169
- data/test/n3.bnf +0 -129
- data/test/test_abc.rb.bak +0 -112
- data/test/test_calc.rb +0 -112
- data/test/test_lambda.rb +0 -87
- data/test/test_metric.rb +0 -617
- data/test/test_owl.rb +0 -1039
- data/test/test_parser.rb +0 -460
- data/test/test_prolog.rb +0 -287
- data/test/test_sql.rb +0 -317
- data/test/test_uri.rb +0 -752
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0166a0d68a1864c4c92132c88f6b74809e317d5c031c5e57bf9951b6aaedc7b8
|
4
|
+
data.tar.gz: 86ae7441a45dbf7c8f168abf2bc4633dc317e8dc11ac29e9e572df3d3f91206b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb4bc055e722070a425921ee0b23e05ae51764d6d76c6f3a955d2c96c3e32eb3eaff0c159710e7b7d067c360efa3308fc55b7868bbc5af94a8df9db1a8903c9b
|
7
|
+
data.tar.gz: a8583f87131780d75a5ed7c46bb49265411fca899921486cf6f854d77c96c98ee41813015b6e5435a0d531bb06e3cf3c12cb2d08bd0effff553ae1e75b839f89
|
data/.document
ADDED
data/.rdoc_options
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
main_page: README
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2007-2009 Akimichi Tatsukawa <akimichi.tatsukawa@gmail.com>
|
2
|
+
Copyright 2024 gemmaro <gemmaro.dev@gmail.com>
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the “Software”), to
|
6
|
+
deal in the Software without restriction, including without limitation the
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
8
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
data/README
CHANGED
@@ -1,57 +1,68 @@
|
|
1
|
-
=
|
1
|
+
= yaparc
|
2
2
|
|
3
|
-
|
3
|
+
== Synopsis
|
4
4
|
|
5
|
-
|
5
|
+
There are several implementations of parser combinator in Ruby. This is an
|
6
|
+
yet another simple combinator parser library in Ruby.
|
6
7
|
|
7
|
-
|
8
|
-
* RubyGem (http://rubyforge.org/projects/rubygems/)
|
8
|
+
== Install
|
9
9
|
|
10
|
-
|
10
|
+
gem install yaparc
|
11
11
|
|
12
|
-
|
12
|
+
== Usage
|
13
13
|
|
14
|
-
|
14
|
+
In combinator parser, each parser is construct as a function taking input
|
15
|
+
string as arguments. Larger parsers are built from smaller parsers. Although
|
16
|
+
combinators are higher-order functions in ordinary functional languages, they
|
17
|
+
are constructed as classes in yaparc, because Ruby has more object-oriented
|
18
|
+
than functional property.
|
15
19
|
|
16
|
-
|
20
|
+
All parsers has +parse+ method, each of which takes input string as its
|
21
|
+
arguments except Yaparc::Satisfy parser. Every parser returns either
|
22
|
+
Yaparc::Result::OK or Yaparc::Result::Fail as their result of parsing. An
|
23
|
+
instance of Yaparc::Result::Fail denotes faiilure, and instance of
|
24
|
+
Yaparc::Result::OK indicates success.
|
17
25
|
|
18
|
-
|
26
|
+
=== Primitive Parsers
|
19
27
|
|
20
|
-
|
28
|
+
* Yaparc::Succeed
|
29
|
+
* Yaparc::Fail
|
30
|
+
* Yaparc::Item
|
31
|
+
* Yaparc::Satisfy
|
21
32
|
|
22
|
-
|
23
|
-
* Fail
|
24
|
-
* Item
|
25
|
-
* Satisfy
|
33
|
+
==== Succeed class
|
26
34
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
The parser Yaparc::Succeed always succeeds with the result value, without
|
36
|
+
consuming any of the input string. In the following example,
|
37
|
+
Yaparc::Succeed#parse takes an input string <tt>blah, blah, blah</tt> and
|
38
|
+
returns the singleton array <tt>[[1, "blah, blah, blah"]]</tt>.
|
31
39
|
|
32
40
|
parser = Yaparc::Succeed.new(1)
|
33
41
|
parser.parse("blah, blah, blah")
|
34
|
-
|
42
|
+
#=> #<Yaparc::Result::OK:0xb7aaaf5c @input="blah, blah, blah", @value=1>
|
35
43
|
|
36
|
-
|
44
|
+
==== Fail class
|
37
45
|
|
38
|
-
The parser Fail always fails, regardless of the contents of the input
|
46
|
+
The parser Yaparc::Fail always fails, regardless of the contents of the input
|
47
|
+
string.
|
39
48
|
|
40
49
|
parser = Yaparc::Fail.new
|
41
50
|
parser.parse("abc")
|
42
|
-
|
51
|
+
#=> #<Yaparc::Result::Fail:0xb7aa56b0 @value=nil>
|
43
52
|
|
44
|
-
|
53
|
+
==== Item class
|
45
54
|
|
46
|
-
The parser Item fails if the input string is empty, and succeeds with
|
55
|
+
The parser Yaparc::Item fails if the input string is empty, and succeeds with
|
56
|
+
the first character as the result value otherwise.
|
47
57
|
|
48
58
|
parser = Yaparc::Item.new
|
49
59
|
parser.parse("abc")
|
50
|
-
|
60
|
+
#=> #<Yaparc::Result::OK:0xb7a9fdb4 @input="bc", @value="a">
|
51
61
|
|
52
|
-
|
62
|
+
==== Satisfy class
|
53
63
|
|
54
|
-
The parser Satisfy recognizes a single input via predicate which
|
64
|
+
The parser Yaparc::Satisfy recognizes a single input via predicate which
|
65
|
+
determines if an arbitrary input is suitable for the predicate.
|
55
66
|
|
56
67
|
is_integer = lambda do |i|
|
57
68
|
begin
|
@@ -63,80 +74,71 @@ The parser Satisfy recognizes a single input via predicate which determines if a
|
|
63
74
|
end
|
64
75
|
parser = Yaparc::Satisfy.new(is_integer)
|
65
76
|
parser.parse("123")
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
== Combining Parsers
|
70
|
-
|
71
|
-
* Alt
|
72
|
-
* Seq
|
73
|
-
* Many
|
74
|
-
* ManyOne
|
77
|
+
#=> #<Yaparc::Result::OK:0xb7a8f284 @input="23", @value="1">
|
75
78
|
|
79
|
+
=== Combining Parsers
|
76
80
|
|
81
|
+
* Yaparc::Alt
|
82
|
+
* Yaparc::Seq
|
83
|
+
* Yaparc::Many
|
84
|
+
* Yaparc::ManyOne
|
77
85
|
|
78
|
-
|
86
|
+
==== Sequencing parser
|
79
87
|
|
80
|
-
The Seq corresponds to sequencing in BNF.
|
88
|
+
The Yaparc::Seq corresponds to sequencing in BNF. The following parser
|
89
|
+
recognizes anything that <tt>Symbol.new('+')</tt> or <tt>Natural.new</tt>
|
90
|
+
would if placed in succession.
|
81
91
|
|
82
92
|
parser = Seq.new(Symbol.new('+'), Natural.new)
|
83
93
|
parser.parse("+321")
|
84
|
-
|
94
|
+
#=> #<Yaparc::Result::OK:0xb7a81ae4 @input="", @value=321>
|
85
95
|
|
86
|
-
|
96
|
+
If a block given to Yaparc::Seq, it analyses input string to construct its
|
97
|
+
logical structure.
|
87
98
|
|
88
|
-
parser = Yaparc::Seq.new(Yaparc::Symbol.new('+'), Yaparc::Natural.new) do |
|
99
|
+
parser = Yaparc::Seq.new(Yaparc::Symbol.new('+'), Yaparc::Natural.new) do |plus, nat|
|
89
100
|
nat
|
90
101
|
end
|
91
102
|
parser.parse("+1234")
|
92
|
-
|
103
|
+
#=> #<Yaparc::Result::OK:0xb7a70a00 @input="", @value=1234>
|
93
104
|
|
94
105
|
It produces a parse tree which expounds the semantic structure of the program.
|
95
106
|
|
96
|
-
|
97
|
-
|
98
|
-
The parser Alt class is an alternation parser, which returns the result of the first parser to succeed, and failure if neither does.
|
107
|
+
==== Alternation parser
|
99
108
|
|
109
|
+
The parser Yaparc::Alt class is an alternation parser, which returns the
|
110
|
+
result of the first parser to succeed, and failure if neither does.
|
100
111
|
|
101
112
|
parser = Yaparc::Alt.new(
|
102
|
-
Yaparc::Seq.new(Yaparc::Symbol.new('+'), Yaparc::Natural.new) do |
|
113
|
+
Yaparc::Seq.new(Yaparc::Symbol.new('+'), Yaparc::Natural.new) do |_, nat|
|
103
114
|
nat
|
104
115
|
end,
|
105
116
|
Yaparc::Natural.new
|
106
117
|
)
|
107
118
|
parser.parse("1234")
|
108
|
-
|
119
|
+
#=> #<Yaparc::Result::OK:0xb7a5a610 @input="", @value=1234>
|
109
120
|
parser.parse("-1234")
|
110
|
-
|
121
|
+
#=> #<Yaparc::Result::Fail:0xb7a57ba4 @value=nil>
|
111
122
|
|
123
|
+
==== Many
|
112
124
|
|
113
|
-
|
114
|
-
|
115
|
-
In Many, zero or more applications of parser are admissible.
|
125
|
+
In Yaparc::Many, zero or more applications of parser are admissible.
|
116
126
|
|
117
127
|
parser = Yaparc::Many.new(Yaparc::Satisfy.new(lambda {|i| i > '0' and i < '9'}))
|
118
128
|
parser.parse("123abc")
|
119
|
-
|
120
|
-
|
121
|
-
=== ManyOne
|
122
|
-
|
123
|
-
The ManyOne requires at least one successfull application of parser.
|
124
|
-
|
129
|
+
#=> #<Yaparc::Result::OK:0xb7a49dc4 @input="abc", @value="123">
|
125
130
|
|
126
|
-
|
131
|
+
==== ManyOne
|
127
132
|
|
128
|
-
|
133
|
+
The Yaparc::ManyOne requires at least one successfull application of parser.
|
129
134
|
|
130
|
-
|
135
|
+
=== Tokenized parser
|
131
136
|
|
132
|
-
|
137
|
+
Yaparc::Identifier :: Parser for identifier
|
138
|
+
Yaparc::Natural :: Parser for natural number
|
139
|
+
Yaparc::Symbol :: Parser for symbol
|
133
140
|
|
134
|
-
|
135
|
-
|
136
|
-
* Symbol
|
137
|
-
|
138
|
-
|
139
|
-
== Regex parser
|
141
|
+
=== Regex parser
|
140
142
|
|
141
143
|
parser = Regex.new(/\A[0-9]+/)
|
142
144
|
result = parser.parse("1234ab")
|
@@ -148,10 +150,10 @@ The ManyOne requires at least one successfull application of parser.
|
|
148
150
|
result = parser.parse("1234:ab")
|
149
151
|
assert_equal ["ab", "1234"], result.value
|
150
152
|
|
153
|
+
=== Define your own parser
|
151
154
|
|
152
|
-
|
153
|
-
|
154
|
-
In order to construct parsers, you make parser class to be inherited from Yaparc::AbstractParser class.
|
155
|
+
In order to construct parsers, you make parser class to be inherited from
|
156
|
+
Yaparc::AbstractParser class.
|
155
157
|
|
156
158
|
class Identifier < Yaparc::AbstractParser
|
157
159
|
def initialize
|
@@ -161,36 +163,54 @@ In order to construct parsers, you make parser class to be inherited from Yaparc
|
|
161
163
|
end
|
162
164
|
end
|
163
165
|
|
164
|
-
If you want to nest the same parser class in the parser definition, you have
|
165
|
-
In the following example, note that Expr class is
|
166
|
+
If you want to nest the same parser class in the parser definition, you have
|
167
|
+
to choose this way. In the following example, note that +Expr+ class is
|
168
|
+
instantiated inside <tt>Expr#initialize</tt> method.
|
166
169
|
|
167
170
|
class Expr < Yaparc::AbstractParser
|
168
171
|
def initialize
|
169
172
|
@parser = lambda do
|
170
173
|
Yaparc::Alt.new(
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
174
|
+
Yaparc::Seq.new(Term.new,
|
175
|
+
Yaparc::Symbol.new('+'),
|
176
|
+
Expr.new) do |term, _, expr|
|
177
|
+
['+', term, expr]
|
178
|
+
end,
|
179
|
+
Term.new
|
180
|
+
)
|
178
181
|
end
|
179
182
|
end
|
183
|
+
end
|
180
184
|
|
181
|
-
Constructing your parsers, it should be noted that left-recursion leads to
|
185
|
+
Constructing your parsers, it should be noted that left-recursion leads to
|
186
|
+
non-termination of the parser.
|
182
187
|
|
183
|
-
|
188
|
+
=== Avoiding left-recursion
|
184
189
|
|
185
190
|
A ::= A B | C
|
186
191
|
|
187
|
-
|
192
|
+
is equivalent to
|
188
193
|
|
189
194
|
A ::= C B*
|
190
195
|
|
196
|
+
=== Tokenization
|
197
|
+
|
198
|
+
When you want to tokenize input stream, use Yaparc::Tokenize class.
|
199
|
+
|
200
|
+
== About this project
|
201
|
+
|
202
|
+
RubyGems.org :: https://rubygems.org/gems/yaparc
|
203
|
+
RubyForge (archived) :: https://web.archive.org/web/20140515235842/http://rubyforge.org/projects/yaparc/
|
204
|
+
|
205
|
+
== Development
|
191
206
|
|
192
|
-
|
207
|
+
After checking out the repo, run <tt>bin/setup</tt> to install dependencies.
|
208
|
+
Then, run <tt>rake test</tt> to run the tests.
|
209
|
+
You can also run <tt>bin/console</tt> for an interactive prompt that will allow you to experiment.
|
193
210
|
|
194
|
-
|
211
|
+
To install this gem onto your local machine, run <tt>bundle exec rake install</tt>.
|
212
|
+
To release a new version, update the version number in the library file, and then run <tt>bundle exec rake release</tt>, which will create a git tag for the version, push git commits and the created tag, and push the <tt>.gem</tt> file to [rubygems.org](https://rubygems.org).
|
195
213
|
|
214
|
+
== Contributing
|
196
215
|
|
216
|
+
Bug reports and pull requests are welcome.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
17
|
+
|
18
|
+
desc 'Generate signatures'
|
19
|
+
task :gensig do
|
20
|
+
sh 'typeprof', '-o', 'sig/yaparc.gen.rbs', 'sig/yaparc.rbs', *Dir['lib/**/*.rb']
|
21
|
+
end
|
data/lib/yaparc.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Yaparc
|
4
|
+
VERSION = "0.3.0"
|
5
|
+
|
2
6
|
module Result
|
3
7
|
class Base
|
4
8
|
attr_accessor :message, :input, :value
|
@@ -454,13 +458,14 @@ module Yaparc
|
|
454
458
|
# Refer to http://www.cs.nott.ac.uk/~gmh/monparsing.pdf, p.23
|
455
459
|
class Identifier
|
456
460
|
include Yaparc::Parsable
|
457
|
-
|
461
|
+
|
462
|
+
IDENTIFIER_REGEX = /\A[a-zA-Z_]+[a-zA-Z0-9_]*/
|
458
463
|
|
459
464
|
def initialize(options = {})
|
460
465
|
identifier_regex = if regex = options[:regex]
|
461
466
|
::Yaparc::Regex.new(regex)
|
462
467
|
else
|
463
|
-
::Yaparc::Regex.new(
|
468
|
+
::Yaparc::Regex.new(IDENTIFIER_REGEX)
|
464
469
|
end
|
465
470
|
|
466
471
|
tokenizer = Tokenize.new(identifier_regex)
|
data/manifest.scm
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
(specifications->manifest (list "ruby@3.1" "ruby-rubocop"))
|
data/sig/yaparc.gen.rbs
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
# TypeProf 0.21.3
|
2
|
+
|
3
|
+
# Classes
|
4
|
+
module Yaparc
|
5
|
+
VERSION: String
|
6
|
+
|
7
|
+
module Result
|
8
|
+
class Base
|
9
|
+
attr_accessor message: nil
|
10
|
+
attr_accessor input: nil
|
11
|
+
attr_accessor value: nil
|
12
|
+
def initialize: (?Hash[untyped, untyped] options) -> void
|
13
|
+
end
|
14
|
+
|
15
|
+
class OK < Base
|
16
|
+
end
|
17
|
+
|
18
|
+
class Fail < Base
|
19
|
+
end
|
20
|
+
|
21
|
+
class Error < Base
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Parsable
|
26
|
+
IS_LOWER: Proc
|
27
|
+
IS_ALPHANUM: Proc
|
28
|
+
IS_DIGIT: Proc
|
29
|
+
IS_SPACE: Proc
|
30
|
+
IS_WHITESPACE: Proc
|
31
|
+
IS_CR: Proc
|
32
|
+
@parser: bot
|
33
|
+
|
34
|
+
attr_accessor tree: untyped
|
35
|
+
def parse: (nil input) -> untyped
|
36
|
+
end
|
37
|
+
|
38
|
+
class Succeed
|
39
|
+
include Parsable
|
40
|
+
@parser: Proc
|
41
|
+
|
42
|
+
attr_reader remaining: nil
|
43
|
+
def initialize: (untyped value, ?nil remaining) -> void
|
44
|
+
end
|
45
|
+
|
46
|
+
class Fail
|
47
|
+
include Parsable
|
48
|
+
@parser: Proc
|
49
|
+
|
50
|
+
def initialize: -> void
|
51
|
+
end
|
52
|
+
|
53
|
+
class Item
|
54
|
+
include Parsable
|
55
|
+
@parser: Proc
|
56
|
+
|
57
|
+
def initialize: -> void
|
58
|
+
end
|
59
|
+
|
60
|
+
class ZeroOne
|
61
|
+
include Parsable
|
62
|
+
@parser: Proc
|
63
|
+
|
64
|
+
def initialize: (untyped parser, ?Array[untyped] identity) -> void
|
65
|
+
end
|
66
|
+
|
67
|
+
class Satisfy
|
68
|
+
include Parsable
|
69
|
+
@parser: Proc
|
70
|
+
|
71
|
+
def initialize: (Proc predicate) -> void
|
72
|
+
def parse: (untyped input) -> untyped
|
73
|
+
end
|
74
|
+
|
75
|
+
class NoFail
|
76
|
+
include Parsable
|
77
|
+
@parser: Proc
|
78
|
+
|
79
|
+
def initialize: (untyped parser) -> void
|
80
|
+
end
|
81
|
+
|
82
|
+
class Seq
|
83
|
+
include Parsable
|
84
|
+
@parser: Proc
|
85
|
+
|
86
|
+
def initialize: (*Char | String | Succeed | WhiteSpace parsers) ?{ (*untyped) -> untyped } -> void
|
87
|
+
end
|
88
|
+
|
89
|
+
class Alt
|
90
|
+
include Parsable
|
91
|
+
@parser: Proc
|
92
|
+
|
93
|
+
def initialize: (*untyped parsers) -> void
|
94
|
+
end
|
95
|
+
|
96
|
+
class Apply
|
97
|
+
include Parsable
|
98
|
+
@parser: Proc
|
99
|
+
|
100
|
+
def initialize: (untyped parser) -> void
|
101
|
+
end
|
102
|
+
|
103
|
+
class String
|
104
|
+
include Parsable
|
105
|
+
@parser: Proc
|
106
|
+
|
107
|
+
def initialize: (untyped string, ?true case_sensitive) -> void
|
108
|
+
end
|
109
|
+
|
110
|
+
class Regex
|
111
|
+
include Parsable
|
112
|
+
@regex: Regexp
|
113
|
+
@parser: Proc
|
114
|
+
|
115
|
+
def initialize: (Regexp regex) -> void
|
116
|
+
end
|
117
|
+
|
118
|
+
class Many
|
119
|
+
include Parsable
|
120
|
+
|
121
|
+
def initialize: (Satisfy parser, ?Array[untyped] | String identity) -> void
|
122
|
+
end
|
123
|
+
|
124
|
+
class ManyOne
|
125
|
+
include Parsable
|
126
|
+
|
127
|
+
def initialize: (Digit parser, ?Array[untyped] | String identity) -> void
|
128
|
+
end
|
129
|
+
|
130
|
+
class Space
|
131
|
+
include Parsable
|
132
|
+
@parser: Proc
|
133
|
+
|
134
|
+
def initialize: -> void
|
135
|
+
end
|
136
|
+
|
137
|
+
class CR
|
138
|
+
include Parsable
|
139
|
+
@parser: Proc
|
140
|
+
|
141
|
+
def initialize: -> void
|
142
|
+
end
|
143
|
+
|
144
|
+
class WhiteSpace
|
145
|
+
include Parsable
|
146
|
+
@parser: Proc
|
147
|
+
|
148
|
+
def initialize: -> void
|
149
|
+
end
|
150
|
+
|
151
|
+
class Tokenize
|
152
|
+
include Parsable
|
153
|
+
@parser: Proc
|
154
|
+
|
155
|
+
attr_accessor prefix: WhiteSpace
|
156
|
+
attr_accessor postfix: WhiteSpace
|
157
|
+
def initialize: (Regex | String parser, ?Hash[untyped, untyped] args) -> void
|
158
|
+
end
|
159
|
+
|
160
|
+
class Literal
|
161
|
+
include Parsable
|
162
|
+
@parser: Proc
|
163
|
+
|
164
|
+
def initialize: (untyped literal, ?true case_sensitive) -> void
|
165
|
+
end
|
166
|
+
|
167
|
+
class Identifier
|
168
|
+
IDENTIFIER_REGEX: Regexp
|
169
|
+
include Parsable
|
170
|
+
@parser: Proc
|
171
|
+
|
172
|
+
def initialize: (?Hash[untyped, untyped] options) -> void
|
173
|
+
end
|
174
|
+
|
175
|
+
class Char
|
176
|
+
include Parsable
|
177
|
+
@parser: Proc
|
178
|
+
|
179
|
+
def initialize: (untyped char, ?true case_sensitive) -> void
|
180
|
+
end
|
181
|
+
|
182
|
+
class Ident
|
183
|
+
include Parsable
|
184
|
+
|
185
|
+
def initialize: -> void
|
186
|
+
end
|
187
|
+
|
188
|
+
class Digit
|
189
|
+
include Parsable
|
190
|
+
@parser: Proc
|
191
|
+
|
192
|
+
def initialize: -> void
|
193
|
+
end
|
194
|
+
|
195
|
+
class Nat
|
196
|
+
include Parsable
|
197
|
+
|
198
|
+
def initialize: -> void
|
199
|
+
end
|
200
|
+
|
201
|
+
class Natural
|
202
|
+
include Parsable
|
203
|
+
|
204
|
+
def initialize: (?Hash[untyped, untyped] args) -> void
|
205
|
+
end
|
206
|
+
|
207
|
+
class Symbol
|
208
|
+
include Parsable
|
209
|
+
@parser: Proc
|
210
|
+
|
211
|
+
def initialize: (untyped literal, ?Hash[untyped, untyped] _args) -> void
|
212
|
+
end
|
213
|
+
|
214
|
+
class AbstractParser
|
215
|
+
include Parsable
|
216
|
+
@parser: bot
|
217
|
+
|
218
|
+
def parse: (untyped input) -> untyped
|
219
|
+
end
|
220
|
+
end
|
data/sig/yaparc.rbs
ADDED
data/yaparc.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/yaparc"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "yaparc"
|
7
|
+
spec.version = Yaparc::VERSION
|
8
|
+
spec.authors = ["Akimichi Tatsukawa", "gemmaro"]
|
9
|
+
spec.email = ["akimichi.tatsukawa@gmail.com", "gemmaro.dev@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Yet another simple parser combinator library"
|
12
|
+
spec.homepage = homepage = "https://git.disroot.org/gemmaro/yaparc"
|
13
|
+
spec.required_ruby_version = ">= 3.1.6"
|
14
|
+
|
15
|
+
spec.files = Dir.chdir(__dir__) do
|
16
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rubocop"
|
25
|
+
spec.add_development_dependency "test-unit"
|
26
|
+
|
27
|
+
spec.metadata = {
|
28
|
+
'rubygems_mfa_required' => 'true',
|
29
|
+
'bug_tracker_uri' => "#{homepage}/issues",
|
30
|
+
'changelog_uri' => "#{homepage}/src/branch/main/CHANGELOG.md",
|
31
|
+
'documentation_uri' => "https://rubydoc.info/gems/yaparc",
|
32
|
+
'homepage_uri' => homepage,
|
33
|
+
'source_code_uri' => homepage,
|
34
|
+
'wiki_uri' => "#{homepage}/wiki",
|
35
|
+
}
|
36
|
+
end
|