lib/ebnf/terminals.rb in ebnf-2.0.0 vs lib/ebnf/terminals.rb in ebnf-2.1.0
- old
+ new
@@ -1,18 +1,21 @@
# encoding: utf-8
# Terminal definitions for the EBNF grammar
module EBNF::Terminals
- SYMBOL = %r([a-zA-Z0-9_\.]+)u.freeze
- HEX = %r(\#x[a-fA-F0-9]+)u.freeze
+ SYMBOL_BASE = %r(\b[a-zA-Z0-9_\.]+\b)u.freeze
+ SYMBOL = %r(#{SYMBOL_BASE}(?!\s*::=))u.freeze
+ HEX = %r(\#x\h+)u.freeze
CHAR = %r([\u0009\u000A\u000D\u0020-\uD7FF\u{10000}-\u{10FFFF}])u.freeze
- R_CHAR = %r([\u0009\u000A\u000D\u0020-\u005C\u005E-\uD7FF\u{10000}-\u{10FFFF}])u.freeze
- RANGE = %r(\[(?:(?:#{R_CHAR})\-(?:#{R_CHAR})|(?:#{HEX})-(?:#{HEX}))\])u.freeze
- ENUM_BASE = %r(\[(?:(?:#{R_CHAR})+|(?:#{HEX})+)\])u.freeze
- ENUM = %r((?:#{ENUM_BASE})(?!\s+#{SYMBOL}))u.freeze
- LHS = %r(\[(?:(?:#{SYMBOL})+\]\s+)?(?:#{SYMBOL})\s*::=)u.freeze
- O_RANGE = %r(\[^(?:#{R_CHAR}\-#{R_CHAR})|(?:#{HEX}-#{HEX})\])u.freeze
- O_ENUM = %r(\[^(?:#{R_CHAR})+\])u.freeze
+ R_CHAR = %r([\u0009\u000A\u000D\u0020-\u002C\u002E-\u005C\u005E-\uD7FF\u{10000}-\u{10FFFF}])u.freeze
+ RANGE = %r(\[(?:(?:#{R_CHAR}\-#{R_CHAR})|(?:#{HEX}\-#{HEX})|#{R_CHAR}|#{HEX})+-?\](?!\s+#{SYMBOL_BASE}\s*::=))u.freeze
+ LHS = %r((?:\[#{SYMBOL_BASE}\])?\s*#{SYMBOL_BASE}\s*::=)u.freeze
+ O_RANGE = %r(\[\^(?:(?:#{R_CHAR}\-#{R_CHAR})|(?:#{HEX}\-#{HEX}|#{R_CHAR}|#{HEX}))+-?\])u.freeze
STRING1 = %r("[\u0009\u000A\u000D\u0020\u0021\u0023-\uD7FF\u{10000}-\u{10FFFF}]*")u.freeze
STRING2 = %r('[\u0009\u000A\u000D\u0020-\u0026\u0028-\uD7FF\u{10000}-\u{10FFFF}]*')u.freeze
POSTFIX = %r([?*+])u.freeze
- PASS = %r((\s|(?:(#[^x]|//)[^\n\r]*$)|(?:/\*(?:(?:\*[^/])|[^*])*\*/))+)mu.freeze
+ PASS = %r((
+ \s
+ | (?:(?:\#[^x]|//)[^\n\r]*)
+ | (?:/\*(?:(?:\*[^/])|[^*])*\*/)
+ | (?:\(\*(?:(?:\*[^\)])|[^*])*\*\))
+ )+)xmu.freeze
end