diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1da320a..05345dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,16 +19,10 @@ jobs: strategy: fail-fast: false matrix: - ruby: - - 2.6 - - 2.7 - - "3.0" - - 3.1 - - ruby-head - - jruby + ruby: [2.6, 2.7, '3.0', 3.1, 3.2, ruby-head, jruby] steps: - name: Clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index e3bafa0..13dc3d6 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -10,7 +10,7 @@ jobs: name: Update gh-pages with docs steps: - name: Clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/VERSION b/VERSION index 2bf1c1c..f90b1af 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3.1 +2.3.2 diff --git a/ebnf.gemspec b/ebnf.gemspec index ad10e61..afdc9f1 100755 --- a/ebnf.gemspec +++ b/ebnf.gemspec @@ -34,13 +34,13 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'scanf', '~> 1.0' gem.add_runtime_dependency 'rdf', '~> 3.2' # Required by sxp gem.add_runtime_dependency 'htmlentities', '~> 4.3' - gem.add_runtime_dependency 'unicode-types', '~> 1.7' - gem.add_runtime_dependency 'amazing_print', '~> 1.4' + gem.add_runtime_dependency 'unicode-types', '~> 1.8' + gem.add_development_dependency 'amazing_print', '~> 1.4' gem.add_development_dependency 'rdf-spec', '~> 3.2' gem.add_development_dependency 'rdf-turtle', '~> 3.2' gem.add_development_dependency 'nokogiri', '~> 1.13', '>= 1.13.4' gem.add_development_dependency 'erubis', '~> 2.7' - gem.add_development_dependency 'rspec', '~> 3.10' + gem.add_development_dependency 'rspec', '~> 3.12' gem.add_development_dependency 'rspec-its', '~> 1.3' gem.add_development_dependency 'yard', '~> 0.9' gem.add_development_dependency 'rake', '~> 13.0' diff --git a/examples/abnf/doc/parser.html b/examples/abnf/doc/parser.html index 2aa0d98..137ecf5 100644 --- a/examples/abnf/doc/parser.html +++ b/examples/abnf/doc/parser.html @@ -466,7 +466,7 @@
-

EBNF Parser for EBNF.

+

EBNF Parser for ABNF.

Produces an Abstract Synatx Tree in S-Expression form for the input grammar file

diff --git a/examples/abnf/parser.rb b/examples/abnf/parser.rb index 3122bd1..60b2000 100644 --- a/examples/abnf/parser.rb +++ b/examples/abnf/parser.rb @@ -1,4 +1,4 @@ -# # EBNF Parser for EBNF. +# # EBNF Parser for ABNF. # # Produces an Abstract Synatx Tree in S-Expression form for the input grammar file require 'ebnf' diff --git a/lib/ebnf/writer.rb b/lib/ebnf/writer.rb index df83056..5de5d91 100644 --- a/lib/ebnf/writer.rb +++ b/lib/ebnf/writer.rb @@ -181,8 +181,9 @@ def initialize(rules, out: $stdout, html: false, format: :ebnf, validate: false, if validate begin + require 'nokogiri' # Validate the output HTML - doc = Nokogiri::HTML5("" + html_result, max_errors: 10) + doc = ::Nokogiri::HTML5("" + html_result, max_errors: 10) raise EncodingError, "Errors found in generated HTML:\n " + doc.errors.map(&:to_s).join("\n ") unless doc.errors.empty? rescue LoadError, NoMethodError @@ -407,14 +408,14 @@ def format_abnf(expr, sep: nil, embedded: false, sensitive: true) seq.unshift(:seq) return format_abnf(seq, sep: nil, embedded: false) else - return (@options[:html] ? %("#{'%s' if sensitive}#{@coder.encode expr}") : %(#{'%s' if sensitive}"#{expr}")) + return (@options[:html] ? %("#{@coder.encode expr}") : %("#{expr}")) end end parts = { - alt: (@options[:html] ? "/ " : "/ "), - star: (@options[:html] ? "* " : "*"), - plus: (@options[:html] ? "+ " : "1*"), - opt: (@options[:html] ? "? " : "?") + alt: (@options[:html] ? "/" : "/ "), + star: (@options[:html] ? "*" : "*"), + plus: (@options[:html] ? "+" : "1*"), + opt: (@options[:html] ? "?" : "?") } lbrac = (@options[:html] ? "[ " : "[") rbrac = (@options[:html] ? "] " : "]") @@ -464,6 +465,8 @@ def format_abnf(expr, sep: nil, embedded: false, sensitive: true) "#{parts[:star]}#{r}" elsif min > 0 && max == '*' "#{min}#{parts[:star]}#{r}" + elsif min == 0 + "#{parts[:star]}#{max}#{r}" else "#{min}#{parts[:star]}#{max}#{r}" end @@ -503,6 +506,7 @@ def format_abnf_range(string) # Append any decimal values alt << "%d" + deces.join(".") unless deces.empty? deces = [] + hex = hex.upcase if in_range # Add "." sequences for any previous hexes @@ -552,7 +556,7 @@ def escape_abnf_hex(u) when 0x0100..0xffff then "%04X" else "%08X" end - char = "%x" + (fmt % u.ord) + char = "%x" + (fmt % u.ord).upcase if @options[:html] if u.ord <= 0x20 char = %(#{@coder.encode char}) diff --git a/spec/writer_spec.rb b/spec/writer_spec.rb index e5891f4..dd76b64 100644 --- a/spec/writer_spec.rb +++ b/spec/writer_spec.rb @@ -319,7 +319,7 @@ ], "rept 0 1": [ [:rept, 0, 1, :A], - "0*1A" + "*1A" ], "rept 0 *": [ [:rept, 0, '*', :A],