ebnf 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ab4040409eda92f9a201dded001390d8b49d9e84b5c4811c1899f8e09f4833e
4
- data.tar.gz: dfe6ff5a7b9bc499744cd76a813bbd951dcb6e5ed34ac6b60208c3543da124a7
3
+ metadata.gz: f58817e075b6100c10ce82eb2da850a71aa9ff76c8d1c359d819720c89477564
4
+ data.tar.gz: 67fb9fc3ae589ae8ab49fef81a5703958635e7b3f8169ccc8df2d17e57c62074
5
5
  SHA512:
6
- metadata.gz: 15add7561aca320bfc785472ce4fbfe4b4f90bd663452b0de86aa9642610f7dadbcd4a881ff94b38209173a4790b415543a406a547264909121118e66eb26e66
7
- data.tar.gz: 187c9239e788592a88679d55531d6b642ac53c3d384b2591c703472b48c35d0fea93267069ce2f1cc5c2c5ac8b7a608d14484bc10ffbb6c555dd9ad597c0214d
6
+ metadata.gz: 13874b6745062e294d15176bba4c482ccdc32974a2733429cb1bc23eb87f608ae6e2deeba4e972bdf236629783c3443d7c8461c90e0db4fc6ef6b39d2564582c
7
+ data.tar.gz: 172c8fa0efc03357f845cabff8d06fb11260cd271cb5a084350f8f432beef8d560cc285cef6ab87f4526d5331d8c4c433ae2b9536e108d2a4e0a7bd522a3292b
data/README.md CHANGED
@@ -101,6 +101,8 @@ On a parsing failure, and exception is raised with information that may be usefu
101
101
  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
102
  [XML 1.0 recommendation](https://www.w3.org/TR/REC-xml/), with minor extensions:
103
103
 
104
+ 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.
105
+
104
106
  The character set for EBNF is UTF-8.
105
107
 
106
108
  The general form of a rule is:
@@ -259,7 +261,8 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
259
261
  list in the the `README`. Alphabetical order applies.
260
262
  * Do note that in order for us to merge any non-trivial changes (as a rule
261
263
  of thumb, additions larger than about 15 lines of code), we need an
262
- explicit [public domain dedication][PDD] on record from you.
264
+ explicit [public domain dedication][PDD] on record from you,
265
+ which you will be asked to agree to on the first commit to a repo within the organization.
263
266
 
264
267
  ## License
265
268
  This is free and unencumbered public domain software. For more information,
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1.2
@@ -24,6 +24,7 @@ module EBNF::PEG
24
24
  # * `opt`: returns the value matched, or `nil` if unmatched.
25
25
  # * `plus`: returns an array of the values matched for the specified production, or `:unmatched`, if none are matched. For Terminals, these are concatenated into a single string.
26
26
  # * `range`: returns a string composed of the values matched, or `:unmatched`, if less than `min` are matched.
27
+ # * `rept`: returns an array of the values matched for the speficied production, or `:unmatched`, if none are matched. For Terminals, these are concatenated into a single string.
27
28
  # * `seq`: returns an array composed of single-entry hashes for each matched production indexed by the production name, or `:unmatched` if any production fails to match. For Terminals, returns a string created by concatenating these values. Via option in a `production` or definition, the result can be a single hash with values for each matched production; note that this is not always possible due to the possibility of repeated productions within the sequence.
28
29
  # * `star`: returns an array of the values matched for the specified production. For Terminals, these are concatenated into a single string.
29
30
  #
@@ -142,6 +143,14 @@ module EBNF::PEG
142
143
  parser.update_furthest_failure(input.pos, input.lineno, expr[1])
143
144
  :unmatched
144
145
  end
146
+ when :rept
147
+ # Result is an array of all expressions while they match,
148
+ # an empty array of none match
149
+ rept = rept(input, expr[1], expr[2], expr[3])
150
+
151
+ # # Update furthest failure for strings and terminals
152
+ parser.update_furthest_failure(input.pos, input.lineno, expr[3]) if terminal?
153
+ rept.is_a?(Array) && terminal? ? rept.join("") : rept
145
154
  when :seq
146
155
  # Evaluate each expression into an array of hashes where each hash contains a key from the associated production and the value is the parsed value of that production. Returns :unmatched if the input does not match the production. Value ordering is ensured by native Hash ordering.
147
156
  seq = expr[1..-1].each_with_object([]) do |prod, accumulator|
@@ -133,7 +133,10 @@ module EBNF
133
133
  OpenStruct.new(id: ("@#{rule.kind}"),
134
134
  sym: nil,
135
135
  assign: nil,
136
- formatted: ("<strong># Productions for terminals</strong>" if rule.kind == :terminals))
136
+ formatted: (
137
+ rule.kind == :terminals ?
138
+ "<strong># Productions for terminals</strong>" :
139
+ self.send(format_meth, rule.expr)))
137
140
  else
138
141
  formatted_expr = self.send(format_meth, rule.expr)
139
142
  # Measure text without markup
@@ -685,9 +688,11 @@ module EBNF
685
688
  <% for rule in @rules %>
686
689
  <tr<%= %{ id="grammar-production-#{rule.sym}"} unless %w(=/ |).include?(rule.assign)%>>
687
690
  <% if rule.id %>
688
- <td><%= rule.id %></td>
691
+ <td<%= " colspan=2" unless rule.sym %>><%= rule.id %></td>
689
692
  <% end %>
693
+ <% if rule.sym %>
690
694
  <td><code><%== rule.sym %></code></td>
695
+ <% end %>
691
696
  <td><%= rule.assign %></td>
692
697
  <td><%= rule.formatted %></td>
693
698
  </tr>
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.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-26 00:00:00.000000000 Z
11
+ date: 2020-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sxp
@@ -246,7 +246,7 @@ homepage: https://github.com/dryruby/ebnf
246
246
  licenses:
247
247
  - Unlicense
248
248
  metadata: {}
249
- post_install_message:
249
+ post_install_message:
250
250
  rdoc_options: []
251
251
  require_paths:
252
252
  - lib
@@ -261,8 +261,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  - !ruby/object:Gem::Version
262
262
  version: '0'
263
263
  requirements: []
264
- rubygems_version: 3.1.3
265
- signing_key:
264
+ rubygems_version: 3.1.4
265
+ signing_key:
266
266
  specification_version: 4
267
267
  summary: EBNF parser and parser generator.
268
268
  test_files: []