Class: ABNF::Compiler::Grammar::Rule

Inherits:
Object
  • Object
show all
Includes:
Compiler
Defined in:
lib/abnf/compiler/grammar/rule.rb

Constant Summary collapse

DELIMITER =
%r{=/?}n

Instance Attribute Summary

Attributes included from Compiler

#match_data, #stream

Instance Method Summary collapse

Methods included from Compiler

included, #initialize

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/abnf/compiler/grammar/rule.rb', line 9

def call
  reference = Rulename.compile stream
  return unless reference

  rulename = reference.rulename
  stream.match C_WSP
  alternative_form = extract_delimiter
  stream.match C_WSP
  alternative = Alternative.compile stream
  stream.match C_NL

  RuleList::Entry.new rulename, alternative, alternative_form
end

#extract_delimiterObject



23
24
25
26
27
# File 'lib/abnf/compiler/grammar/rule.rb', line 23

def extract_delimiter
  match_data = stream.match DELIMITER
  return unless match_data
  match_data.to_s == '=/'.freeze
end