Class: GrammarSymbol

Inherits:
Element show all
Defined in:
lib/rpdf2txt-rockit/grammar.rb

Direct Known Subclasses

NonTerminal

Instance Attribute Summary collapse

Attributes inherited from Element

#sub_elements, #tree_specification

Instance Method Summary collapse

Methods inherited from Element

#normalize

Methods included from SourceCodeDumpable

as_code, as_method_named, as_module_method_named, #create_new, indent_lines, name_hash, #new_of_my_type, #parameter_named, #to_compact_src, #to_src_in_module, #type_to_src

Constructor Details

#initialize(name) ⇒ GrammarSymbol

Returns a new instance of GrammarSymbol.



318
319
320
321
# File 'lib/rpdf2txt-rockit/grammar.rb', line 318

def initialize(name)
  super(nil, nil) # Symbols have no sub-elements or tree-specification
  @name = name.to_s
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



317
318
319
# File 'lib/rpdf2txt-rockit/grammar.rb', line 317

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



323
324
325
326
327
# File 'lib/rpdf2txt-rockit/grammar.rb', line 323

def ==(other)
  #Profiler.__enter__("GrammarSymbol#==".intern, other)
  res = other.kind_of?(GrammarSymbol) and name == other.name
  #Profiler.__leave__("GrammarSymbol#==".intern, res)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


333
334
335
# File 'lib/rpdf2txt-rockit/grammar.rb', line 333

def eql?(other)
  other.hash == hash
end

#hashObject



329
330
331
# File 'lib/rpdf2txt-rockit/grammar.rb', line 329

def hash
  name.hash
end

#inspectObject



337
338
339
# File 'lib/rpdf2txt-rockit/grammar.rb', line 337

def inspect
  name
end

#to_src(assignToName = nil, nameHash = {}) ⇒ Object



341
342
343
# File 'lib/rpdf2txt-rockit/grammar.rb', line 341

def to_src(assignToName = nil, nameHash = {})
  assign_to(assignToName, new_of_my_type(name))
end