Skip to content

Commit 3faa59d

Browse files
committed
Finish 2.3.1
2 parents 6be5db0 + 5bea26f commit 3faa59d

9 files changed

Lines changed: 56 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
ruby:
2323
- 2.6
2424
- 2.7
25-
- 3.0
25+
- "3.0"
2626
- 3.1
2727
- ruby-head
2828
- jruby
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build & deploy documentation
2+
on:
3+
push:
4+
branches:
5+
- master
6+
workflow_dispatch:
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
name: Update gh-pages with docs
11+
steps:
12+
- name: Clone repository
13+
uses: actions/checkout@v2
14+
- name: Set up Ruby
15+
uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: "3.1"
18+
- name: Install required gem dependencies
19+
run: gem install yard --no-document
20+
- name: Build YARD Ruby Documentation
21+
run: yardoc
22+
- name: Deploy
23+
uses: peaceiris/actions-gh-pages@v3
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
publish_dir: ./doc/yard
27+
publish_branch: gh-pages

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
## Description
1111
This is a [Ruby][] implementation of an [EBNF][] and [BNF][] parser and parser generator.
1212

13-
### [PEG][]/[Packrat][] Parser
14-
In the primary mode, it supports a Parsing Expression Grammar ([PEG][]) parser generator. This performs more minmal transformations on the parsed grammar to extract sub-productions, which allows each component of a rule to generate its own parsing event.
13+
### [PEG][] / [Packrat][] Parser
14+
In the primary mode, it supports a Parsing Expression Grammar ([PEG][]) parser generator. This performs more minimal transformations on the parsed grammar to extract sub-productions, which allows each component of a rule to generate its own parsing event.
1515

1616
The resulting {EBNF::PEG::Rule} objects then parse each associated rule according to the operator semantics and use a [Packrat][] memoizer to reduce extra work when backtracking.
1717

@@ -77,13 +77,13 @@ Generate formatted grammar using HTML (requires [Haml][Haml] gem):
7777

7878
The EBNF gem can also parse [ISO/EIC 14977] Grammars (ISOEBNF) to [S-Expressions][S-Expression].
7979

80-
grammar = EBNF.parse(File.open('./etc/iso-ebnf.isoebnf', format: :isoebnf))
80+
grammar = EBNF.parse(File.open('./etc/iso-ebnf.isoebnf'), format: :isoebnf)
8181

8282
### Parsing an ABNF Grammar
8383

8484
The EBNF gem can also parse [ABNF] Grammars to [S-Expressions][S-Expression].
8585

86-
grammar = EBNF.parse(File.open('./etc/abnf.abnf', format: :abnf))
86+
grammar = EBNF.parse(File.open('./etc/abnf.abnf'), format: :abnf)
8787

8888
### Parser Debugging
8989

@@ -278,7 +278,7 @@ A copy of the [Turtle EBNF][] and derived parser files are included in the repos
278278
[ABNF]: https://www.rfc-editor.org/rfc/rfc5234
279279
[BNF]: https://en.wikipedia.org/wiki/Backus–Naur_form
280280
[EBNF]: https://www.w3.org/TR/REC-xml/#sec-notation
281-
[EBNF doc]: https://rubydoc.info/github/dryruby/ebnf
281+
[EBNF doc]: https://dryruby.github.io/ebnf
282282
[First/Follow]: https://en.wikipedia.org/wiki/LL_parser#Constructing_an_LL.281.29_parsing_table
283283
[ISO/IEC 14977]:https://www.iso.org/standard/26153.html
284284
[LL(1)]: https://www.csd.uwo.ca/~moreno//CS447/Lectures/Syntax.html/node14.html

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.0
1+
2.3.1

ebnf.gemspec

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Gem::Specification.new do |gem|
1010
gem.license = 'Unlicense'
1111
gem.summary = "EBNF parser and parser generator in Ruby."
1212
gem.description = %q{EBNF is a Ruby parser for W3C EBNF and a parser generator for PEG and LL(1). Also includes parsing modes for ISO EBNF and ABNF.}
13+
gem.metadata = {
14+
"documentation_uri" => "https://dryruby.github.io/ebnf",
15+
"bug_tracker_uri" => "https://github.com/dryruby/ebnf/issues",
16+
"homepage_uri" => "https://github.com/dryruby/ebnf",
17+
"source_code_uri" => "https://github.com/dryruby/ebnf",
18+
}
1319

1420
gem.authors = ['Gregg Kellogg']
1521
gem.email = 'public-rdf-ruby@w3.org'

examples/ebnf-peg-parser/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ The `ebnf` production uses the `alt` operator. When matching the production itse
158158
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
159159
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
160160
[EBNF]: https://www.w3.org/TR/REC-xml/#sec-notation
161-
[EBNF doc]: https://rubydoc.info/github/dryruby/ebnf/
161+
[EBNF doc]: https://dryruby.github.io/ebnf
162162
[Packrat]: https://pdos.csail.mit.edu/~baford/packrat/thesis/
163163
[PEG]: https://en.wikipedia.org/wiki/Parsing_expression_grammar
164164
[S-expression]: https://en.wikipedia.org/wiki/S-expression

examples/isoebnf/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Looking at the grammar itself, we can see that the first declaration is
129129
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
130130
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
131131
[EBNF]: https://www.w3.org/TR/REC-xml/#sec-notation
132-
[EBNF doc]: https://rubydoc.info/github/dryruby/ebnf/
132+
[EBNF doc]: https://dryruby.github.io/ebnf
133133
[Packrat]: https://pdos.csail.mit.edu/~baford/packrat/thesis/
134134
[PEG]: https://en.wikipedia.org/wiki/Parsing_expression_grammar
135135
[ISO/IEC 14977]:https://www.iso.org/standard/26153.html

lib/ebnf/rule.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ def to_peg
367367
def to_regexp
368368
case expr.first
369369
when :hex
370-
Regexp.new(translate_codepoints(expr[1]))
370+
Regexp.new(Regexp.escape(translate_codepoints(expr[1])))
371371
when :istr
372372
/#{expr.last}/ui
373373
when :range
374-
Regexp.new("[#{translate_codepoints(expr[1])}]")
374+
Regexp.new("[#{escape_regexp_character_range(translate_codepoints(expr[1]))}]")
375375
else
376376
raise "Can't turn #{expr.inspect} into a regexp"
377377
end
@@ -770,5 +770,11 @@ def make_sym_id(variation = nil)
770770
@id_seq += 1
771771
["_#{@sym}_#{@id_seq}#{variation}".to_sym, ("#{@id}.#{@id_seq}#{variation}" if @id)]
772772
end
773+
774+
# Escape "[", "]", and "\" in ranges so they don't result in a warning or error
775+
# about empty character classes.
776+
def escape_regexp_character_range(character_range)
777+
character_range.gsub(/([\[\]\\])/) {|char| "\\#{char}"}
778+
end
773779
end
774-
end
780+
end

spec/rule_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,13 @@
481481
describe "#to_regexp" do
482482
{
483483
hex: [:hex, "#x20", / /],
484+
hex: [:hex, "#x5c", /\\/],
484485
range: [:range, "a-b", /[a-b]/],
485486
range2: [:range, "a-zA-Z", /[a-zA-Z]/],
486487
range3: [:range, "abc-", /[abc-]/],
488+
range4: [:range, "#x23-#x5b", /[#-\[]/],
489+
range5: [:range, "#x5d-#x5e", /[\]-^]/],
490+
range6: [:range, "#x5c-#x5e", /[\\-^]/],
487491
}.each do |title, (op, exp, regexp)|
488492
it title do
489493
expect(EBNF::Rule.new(title, nil, [op, exp]).to_regexp).to eql regexp
@@ -1055,4 +1059,4 @@
10551059
end
10561060
end
10571061
end
1058-
end
1062+
end

0 commit comments

Comments
 (0)