ebnf 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/VERSION +1 -1
- data/lib/ebnf/rule.rb +9 -3
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8591cff439890326aadd4187c5ccb7561d6a6f5f3cd3bc213ae6f23f4d689de
|
4
|
+
data.tar.gz: c53fad830e7de8dbf0d0e7aa477989b2130fa6fbee0c054a2a199689a3ebc6f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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://
|
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.
|
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.
|
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:
|
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:
|