Sha256: c36a052f9fe59292bb2a5700dd1d74ef2a51cd36ff4996ce597fab52eee2fa17
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module EBNF module PEG autoload :Parser, 'ebnf/peg/parser' autoload :Rule, 'ebnf/peg/rule' ## # Transform EBNF Rule set for PEG parsing: # # * Transform each rule into a set of sub-rules extracting unnamed sequences into new rules, using {Rule#to_peg}. # @return [ENBF] self def make_peg progress("make_peg") {"Start: #{@ast.length} rules"} new_ast = [] ast.each do |rule| debug("make_peg") {"expand from: #{rule.inspect}"} new_rules = rule.to_peg debug(" => ") {new_rules.map(&:sym).join(', ')} new_ast += new_rules end @ast = new_ast progress("make_peg") {"End: #{@ast.length} rules"} self end ## # Output Ruby parser files for PEG parsing # # @param [IO, StringIO] output def to_ruby_peg(output, **options) output.puts " RULES = [" ast.each do |rule| output.puts " " + rule.to_ruby + '.extend(EBNF::PEG::Rule),' end output.puts " ]" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ebnf-2.0.0 | lib/ebnf/peg.rb |