Class: Rley::Syntax::SymbolSeq
- Inherits:
-
Object
- Object
- Rley::Syntax::SymbolSeq
- Extended by:
- Forwardable
- Defined in:
- lib/rley/syntax/symbol_seq.rb
Overview
A symbol sequence is a suite of grammar symbols
Instance Attribute Summary collapse
-
#members ⇒ Array<GrmSymbol>
readonly
The sequence of symbols.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Equality operator.
-
#initialize(theSymbols) ⇒ SymbolSeq
constructor
Create a sequence of grammar symbols (as in right-hand side of a production rule).
-
#inspect ⇒ String
Returns a string containing a human-readable representation of the sequence of symbols.
Constructor Details
#initialize(theSymbols) ⇒ SymbolSeq
Create a sequence of grammar symbols (as in right-hand side of a production rule).
18 19 20 |
# File 'lib/rley/syntax/symbol_seq.rb', line 18 def initialize(theSymbols) @members = theSymbols.dup end |
Instance Attribute Details
#members ⇒ Array<GrmSymbol> (readonly)
Returns The sequence of symbols.
13 14 15 |
# File 'lib/rley/syntax/symbol_seq.rb', line 13 def members @members end |
Instance Method Details
#==(other) ⇒ Boolean
Equality operator.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rley/syntax/symbol_seq.rb', line 25 def ==(other) return true if equal?(other) case other when SymbolSeq then result = other.members == members when Array then result = other == members else msg = "Cannot compare a SymbolSeq with a #{other.class}" raise StandardError, msg end result end |
#inspect ⇒ String
Returns a string containing a human-readable representation of the sequence of symbols.
42 43 44 45 46 47 |
# File 'lib/rley/syntax/symbol_seq.rb', line 42 def inspect result = +"#<#{self.class.name}:#{object_id}" symbol_names = members.map(&:name) result << " @members=#{symbol_names}>" result end |