Sha256: d0d3d483b439d5073015a2add09f440399f718e4c5edff85e2f77759f2cdddaa
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
module Antelope module DSL module Contexts # The main context of the Antelope DSL. class Main < Base def define(pass) pass.each do |key, value| case value when Array @defines[key] = value else @defines[key] = [value] end end end def terminals(&block) @terminals.merge! context(Terminal, &block) end def precedences(&block) @precedences = context(Precedence, &block) end def productions(&block) @productions = context(Production, &block) end def template(template) case template when Hash @templates.merge(template) when String @templates[:default] = template else raise ArgumentError, "Unexpected #{template.class}, " \ "expected String or Hash" end end private def before_call @defines = {} @templates = {} @terminals = {} @precedences = [] @productions = [] end def data { defines: @defines, templates: @templates, terminals: @terminals, precedences: @precedences, productions: @productions } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems