class ABNF::Parser::Compiler
Attributes
output[RW]
tokens[R]
Public Class Methods
build(abnf, include_common: nil)
click to toggle source
# File lib/abnf/parser/compiler.rb, line 12 def self.build abnf, include_common: nil include_common ||= false if include_common common_rule_list = Parser::RuleList.common end tokenizer = Tokenizer.build abnf instance = new tokenizer, common_rule_list instance.push RuleList instance end
call(*arguments)
click to toggle source
# File lib/abnf/parser/compiler.rb, line 25 def self.call *arguments instance = build *arguments instance.() instance.rule_list end
new(tokens, rule_list=nil)
click to toggle source
# File lib/abnf/parser/compiler.rb, line 7 def initialize tokens, rule_list=nil @tokens = tokens @rule_list = rule_list end
Public Instance Methods
call()
click to toggle source
# File lib/abnf/parser/compiler.rb, line 31 def call tokens.each do |token| handle token end output end
current_frame()
click to toggle source
# File lib/abnf/parser/compiler.rb, line 39 def current_frame stack.last end
handle(token)
click to toggle source
# File lib/abnf/parser/compiler.rb, line 43 def handle token return unless current_frame current_frame.(token) end
pop(rule)
click to toggle source
# File lib/abnf/parser/compiler.rb, line 48 def pop rule frame = stack.pop self.output = rule if stack.empty? frame.exited rule end
push(rule_builder_cls, &block)
click to toggle source
# File lib/abnf/parser/compiler.rb, line 56 def push rule_builder_cls, &block rule_builder = rule_builder_cls.new self frame = Frame.new rule_builder, block stack.push frame end
root()
click to toggle source
# File lib/abnf/parser/compiler.rb, line 62 def root stack.first end
rule_list()
click to toggle source
# File lib/abnf/parser/compiler.rb, line 66 def rule_list @rule_list ||= Parser::RuleList.new end
stack()
click to toggle source
# File lib/abnf/parser/compiler.rb, line 70 def stack @stack ||= [] end