ebnf 2.3.0 → 2.3.1

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/VERSION +1 -1
  4. data/lib/ebnf/rule.rb +9 -3
  5. metadata +7 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c56b57d125d152b6bfcd4c77b3a2d160ba1e7e11fc538c182085868fe5b2d4a4
4
- data.tar.gz: c7c3987ce05152cc1efa031f0ecc03f2bc111442fbcbbcb3d2cf82b85f59e4cf
3
+ metadata.gz: e8591cff439890326aadd4187c5ccb7561d6a6f5f3cd3bc213ae6f23f4d689de
4
+ data.tar.gz: c53fad830e7de8dbf0d0e7aa477989b2130fa6fbee0c054a2a199689a3ebc6f0
5
5
  SHA512:
6
- metadata.gz: 9692cedc65cfde26fd21781f01a3f44c52f69de178893b63ce94b74e9a9ef24218979a9693eec18c02469bf69ea9b15a9b248817958b5c6a6874ec078ac02091
7
- data.tar.gz: dc8c937d4ba0f70e4b981cd4c91a40b2cd59c6803e1b5409f5bdc8f5dea6acc4af2c176f26e1cde805077c035aa93baf3d8e0b15858238380e2a1c25a6f1c32b
6
+ metadata.gz: 07f515ffbfaa5de085c9b63bf7e12ef84428a28fc35f727bc0956557c7e4270213eb51104950befec53c97105f992edea848bc30b22b21e07843bca818edbe63
7
+ data.tar.gz: 3433f6cfb3de5009caf7013ece30f50bec35aeff65d71dbce7235f753d81d7ab88ce09468cd9d9c0759a453ea9535dd5e9a01ee954837b1f318b4524a9658eec
data/README.md CHANGED
@@ -10,8 +10,8 @@
10
10
  ## Description
11
11
  This is a [Ruby][] implementation of an [EBNF][] and [BNF][] parser and parser generator.
12
12
 
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.
15
15
 
16
16
  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.
17
17
 
@@ -77,13 +77,13 @@ Generate formatted grammar using HTML (requires [Haml][Haml] gem):
77
77
 
78
78
  The EBNF gem can also parse [ISO/EIC 14977] Grammars (ISOEBNF) to [S-Expressions][S-Expression].
79
79
 
80
- grammar = EBNF.parse(File.open('./etc/iso-ebnf.isoebnf', format: :isoebnf))
80
+ grammar = EBNF.parse(File.open('./etc/iso-ebnf.isoebnf'), format: :isoebnf)
81
81
 
82
82
  ### Parsing an ABNF Grammar
83
83
 
84
84
  The EBNF gem can also parse [ABNF] Grammars to [S-Expressions][S-Expression].
85
85
 
86
- grammar = EBNF.parse(File.open('./etc/abnf.abnf', format: :abnf))
86
+ grammar = EBNF.parse(File.open('./etc/abnf.abnf'), format: :abnf)
87
87
 
88
88
  ### Parser Debugging
89
89
 
@@ -278,7 +278,7 @@ A copy of the [Turtle EBNF][] and derived parser files are included in the repos
278
278
  [ABNF]: https://www.rfc-editor.org/rfc/rfc5234
279
279
  [BNF]: https://en.wikipedia.org/wiki/Backus–Naur_form
280
280
  [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
282
282
  [First/Follow]: https://en.wikipedia.org/wiki/LL_parser#Constructing_an_LL.281.29_parsing_table
283
283
  [ISO/IEC 14977]:https://www.iso.org/standard/26153.html
284
284
  [LL(1)]: https://www.csd.uwo.ca/~moreno//CS447/Lectures/Syntax.html/node14.html
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.3.1
data/lib/ebnf/rule.rb CHANGED
@@ -367,11 +367,11 @@ module EBNF
367
367
  def to_regexp
368
368
  case expr.first
369
369
  when :hex
370
- Regexp.new(translate_codepoints(expr[1]))
370
+ Regexp.new(Regexp.escape(translate_codepoints(expr[1])))
371
371
  when :istr
372
372
  /#{expr.last}/ui
373
373
  when :range
374
- Regexp.new("[#{translate_codepoints(expr[1])}]")
374
+ Regexp.new("[#{escape_regexp_character_range(translate_codepoints(expr[1]))}]")
375
375
  else
376
376
  raise "Can't turn #{expr.inspect} into a regexp"
377
377
  end
@@ -770,5 +770,11 @@ module EBNF
770
770
  @id_seq += 1
771
771
  ["_#{@sym}_#{@id_seq}#{variation}".to_sym, ("#{@id}.#{@id_seq}#{variation}" if @id)]
772
772
  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
773
779
  end
774
- end
780
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebnf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-08 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sxp
@@ -274,7 +274,11 @@ files:
274
274
  homepage: https://github.com/dryruby/ebnf
275
275
  licenses:
276
276
  - Unlicense
277
- metadata: {}
277
+ metadata:
278
+ documentation_uri: https://dryruby.github.io/ebnf
279
+ bug_tracker_uri: https://github.com/dryruby/ebnf/issues
280
+ homepage_uri: https://github.com/dryruby/ebnf
281
+ source_code_uri: https://github.com/dryruby/ebnf
278
282
  post_install_message:
279
283
  rdoc_options: []
280
284
  require_paths: