Module: Citrus::Nonterminal

Includes:
Rule
Included in:
AndPredicate, ButPredicate, Choice, NotPredicate, Repeat, Sequence
Defined in:
lib/citrus.rb

Overview

A Nonterminal is a Rule that augments the matching behavior of one or more other rules. Nonterminals may not match directly on the input, but instead invoke the rule(s) they contain to determine if a match can be made from the collective result.

Instance Attribute Summary collapse

Attributes included from Rule

#extension, #grammar, #label, #name

Instance Method Summary collapse

Methods included from Rule

#==, #===, #default_options, #elide?, #extend_match, for, #inspect, #needs_paren?, #parse, #terminal?, #test, #to_embedded_s, #to_s

Instance Attribute Details

#rules ⇒ Object (readonly)

An array of the actual Rule objects this rule uses to match.



984
985
986
# File 'lib/citrus.rb', line 984

def rules
  @rules
end

Instance Method Details

#grammar=(grammar) ⇒ Object

:nodoc:



986
987
988
989
# File 'lib/citrus.rb', line 986

def grammar=(grammar) # :nodoc:
  super
  @rules.each {|r| r.grammar = grammar }
end

#initialize(rules = []) ⇒ Object



979
980
981
# File 'lib/citrus.rb', line 979

def initialize(rules=[])
  @rules = rules.map {|r| Rule.for(r) }
end