ebnf 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -3
  3. data/VERSION +1 -1
  4. data/lib/ebnf/writer.rb +11 -7
  5. metadata +16 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8591cff439890326aadd4187c5ccb7561d6a6f5f3cd3bc213ae6f23f4d689de
4
- data.tar.gz: c53fad830e7de8dbf0d0e7aa477989b2130fa6fbee0c054a2a199689a3ebc6f0
3
+ metadata.gz: 2c74fb8dfe53ab905e6c329a9135845b7a8064b64755d594a0595ae7ab52316a
4
+ data.tar.gz: 76d3101062440b05bb878cf626c67b4891abeaa99754568a181ca583d2115f57
5
5
  SHA512:
6
- metadata.gz: 07f515ffbfaa5de085c9b63bf7e12ef84428a28fc35f727bc0956557c7e4270213eb51104950befec53c97105f992edea848bc30b22b21e07843bca818edbe63
7
- data.tar.gz: 3433f6cfb3de5009caf7013ece30f50bec35aeff65d71dbce7235f753d81d7ab88ce09468cd9d9c0759a453ea9535dd5e9a01ee954837b1f318b4524a9658eec
6
+ metadata.gz: 7252bcc2e3f658607d89db824a0e56a67d5b4ab7a0b21fa194269e03fbf8813dfe27ae8172d51282f86d2abb326e590d506e2fd1374b74eba763d2e3179b71f2
7
+ data.tar.gz: 38511111c2a6769741b85893d5df222c5d4ab39f62fabc8a97fb4aff9bf5784ae9e75e9a56e2e4bf0553c46ae369b56c53e6fd3ab6be74c2b0e69357cc51382a
data/README.md CHANGED
@@ -99,7 +99,9 @@ The formatted HTML results are designed to be appropriate for including in speci
99
99
  On a parsing failure, and exception is raised with information that may be useful in determining the source of the error.
100
100
 
101
101
  ## EBNF Grammar
102
- The [EBNF][] variant used here is based on [W3C](https://w3.org/) [EBNF][] (see {file:etc/ebnf.ebnf EBNF grammar}) as defined in the
102
+ The [EBNF][] variant used here is based on [W3C](https://w3.org/) [EBNF][]
103
+ (see [EBNF grammar](https://dryruby.github.io/ebnf/etc/ebnf.ebnf))
104
+ as defined in the
103
105
  [XML 1.0 recommendation](https://www.w3.org/TR/REC-xml/), with minor extensions:
104
106
 
105
107
  Note that the grammar includes an optional `[identifer]` in front of rule names, which can be in conflict with the `RANGE` terminal. It is typically not a problem, but if it comes up, try parsing with the `native` parser, add comments or sequences to disambiguate. EBNF does not have beginning of line checks as all whitespace is treated the same, so the common practice of identifying each rule inherently leads to such ambiguity.
@@ -161,7 +163,12 @@ Within the expression on the right-hand side of a rule, the following expression
161
163
  * `@pass` defines the expression used to detect whitespace, which is removed in processing.
162
164
  * No support for `wfc` (well-formedness constraint) or `vc` (validity constraint).
163
165
 
164
- Parsing this grammar yields an [S-Expression][] version: {file:etc/ebnf.sxp} (or [LL(1)][] version {file:etc/ebnf.ll1.sxp} or [PEG][] version {file:etc/ebnf.peg.sxp}).
166
+ Parsing this grammar yields an [S-Expression][S-Expression] version:
167
+ [here](https://dryruby.github.io/ebnf/etc/ebnf.sxp)
168
+ (or [LL(1)][] version
169
+ [here](https://dryruby.github.io/ebnf/etc/ebnf.ll1.sxp)
170
+ or [PEG][] version
171
+ [here](https://dryruby.github.io/ebnf/etc/ebnf.peg.sxp)).
165
172
 
166
173
  ### Parser S-Expressions
167
174
  Intermediate representations of the grammar may be serialized to Lisp-like [S-Expressions][S-Expression]. For example, the rule
@@ -225,7 +232,7 @@ For a [PEG][] parser for a simple grammar implementing a calculator see [Calc ex
225
232
  For an example parser built using this gem that parses the [EBNF][] grammar, see [EBNF PEG Parser example](https://dryruby.github.io/ebnf/examples/ebnf-peg-parser/doc/parser.html). This example creates a parser for the [EBNF][] grammar which generates the same Abstract Syntax Tree as the built-in parser in the gem.
226
233
 
227
234
  There is also an
228
- [EBNF LL(1) Parser example](https://dryruby.github.io/ebnf/examples/ebnf-peg-parser/doc/parser.html).
235
+ [EBNF LL(1) Parser example](https://dryruby.github.io/ebnf/examples/ebnf-ll1-parser/doc/parser.html).
229
236
 
230
237
  The [ISO EBNF Parser](https://dryruby.github.io/ebnf/examples/isoebnf/doc/parser.html) example parses [ISO/IEC 14977][] into [S-Expressions][S-Expression], which can be used to parse compatible grammars using this parser (either [PEG][] or [LL(1)][]).
231
238
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.3.2
data/lib/ebnf/writer.rb CHANGED
@@ -181,8 +181,9 @@ module EBNF
181
181
 
182
182
  if validate
183
183
  begin
184
+ require 'nokogiri'
184
185
  # Validate the output HTML
185
- doc = Nokogiri::HTML5("<!DOCTYPE html>" + html_result, max_errors: 10)
186
+ doc = ::Nokogiri::HTML5("<!DOCTYPE html>" + html_result, max_errors: 10)
186
187
  raise EncodingError, "Errors found in generated HTML:\n " +
187
188
  doc.errors.map(&:to_s).join("\n ") unless doc.errors.empty?
188
189
  rescue LoadError, NoMethodError
@@ -407,14 +408,14 @@ module EBNF
407
408
  seq.unshift(:seq)
408
409
  return format_abnf(seq, sep: nil, embedded: false)
409
410
  else
410
- return (@options[:html] ? %("<code class="grammar-literal">#{'%s' if sensitive}#{@coder.encode expr}</code>") : %(#{'%s' if sensitive}"#{expr}"))
411
+ return (@options[:html] ? %("<code class="grammar-literal">#{@coder.encode expr}</code>") : %("#{expr}"))
411
412
  end
412
413
  end
413
414
  parts = {
414
- alt: (@options[:html] ? "<code>/</code> " : "/ "),
415
- star: (@options[:html] ? "<code>*</code> " : "*"),
416
- plus: (@options[:html] ? "<code>+</code> " : "1*"),
417
- opt: (@options[:html] ? "<code>?</code> " : "?")
415
+ alt: (@options[:html] ? "<code>/</code>" : "/ "),
416
+ star: (@options[:html] ? "<code>*</code>" : "*"),
417
+ plus: (@options[:html] ? "<code>+</code>" : "1*"),
418
+ opt: (@options[:html] ? "<code>?</code>" : "?")
418
419
  }
419
420
  lbrac = (@options[:html] ? "<code>[</code> " : "[")
420
421
  rbrac = (@options[:html] ? "<code>]</code> " : "]")
@@ -464,6 +465,8 @@ module EBNF
464
465
  "#{parts[:star]}#{r}"
465
466
  elsif min > 0 && max == '*'
466
467
  "#{min}#{parts[:star]}#{r}"
468
+ elsif min == 0
469
+ "#{parts[:star]}#{max}#{r}"
467
470
  else
468
471
  "#{min}#{parts[:star]}#{max}#{r}"
469
472
  end
@@ -503,6 +506,7 @@ module EBNF
503
506
  # Append any decimal values
504
507
  alt << "%d" + deces.join(".") unless deces.empty?
505
508
  deces = []
509
+ hex = hex.upcase
506
510
 
507
511
  if in_range
508
512
  # Add "." sequences for any previous hexes
@@ -552,7 +556,7 @@ module EBNF
552
556
  when 0x0100..0xffff then "%04X"
553
557
  else "%08X"
554
558
  end
555
- char = "%x" + (fmt % u.ord)
559
+ char = "%x" + (fmt % u.ord).upcase
556
560
  if @options[:html]
557
561
  if u.ord <= 0x20
558
562
  char = %(<abbr title="#{ASCII_ESCAPE_NAMES[u.ord]}">#{@coder.encode char}</abbr>)
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.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-23 00:00:00.000000000 Z
11
+ date: 2023-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sxp
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.7'
75
+ version: '1.8'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.7'
82
+ version: '1.8'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: amazing_print
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -87,7 +87,7 @@ dependencies:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.4'
90
- type: :runtime
90
+ type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
@@ -128,14 +128,20 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.12'
131
+ version: '1.13'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.13.4
132
135
  type: :development
133
136
  prerelease: false
134
137
  version_requirements: !ruby/object:Gem::Requirement
135
138
  requirements:
136
139
  - - "~>"
137
140
  - !ruby/object:Gem::Version
138
- version: '1.12'
141
+ version: '1.13'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 1.13.4
139
145
  - !ruby/object:Gem::Dependency
140
146
  name: erubis
141
147
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +162,14 @@ dependencies:
156
162
  requirements:
157
163
  - - "~>"
158
164
  - !ruby/object:Gem::Version
159
- version: '3.10'
165
+ version: '3.12'
160
166
  type: :development
161
167
  prerelease: false
162
168
  version_requirements: !ruby/object:Gem::Requirement
163
169
  requirements:
164
170
  - - "~>"
165
171
  - !ruby/object:Gem::Version
166
- version: '3.10'
172
+ version: '3.12'
167
173
  - !ruby/object:Gem::Dependency
168
174
  name: rspec-its
169
175
  requirement: !ruby/object:Gem::Requirement
@@ -294,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
294
300
  - !ruby/object:Gem::Version
295
301
  version: '0'
296
302
  requirements: []
297
- rubygems_version: 3.3.3
303
+ rubygems_version: 3.4.6
298
304
  signing_key:
299
305
  specification_version: 4
300
306
  summary: EBNF parser and parser generator in Ruby.