Class: Racc::UserAction

Inherits:
Object show all
Defined in:
lib/racc/grammar.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, proc) ⇒ UserAction

Returns a new instance of UserAction.



741
742
743
744
# File 'lib/racc/grammar.rb', line 741

def initialize(src, proc)
  @source = src
  @proc = proc
end

Instance Attribute Details

#procObject (readonly)

Returns the value of attribute proc.



747
748
749
# File 'lib/racc/grammar.rb', line 747

def proc
  @proc
end

#sourceObject (readonly)

Returns the value of attribute source.



746
747
748
# File 'lib/racc/grammar.rb', line 746

def source
  @source
end

Class Method Details

.emptyObject



735
736
737
# File 'lib/racc/grammar.rb', line 735

def UserAction.empty
  new(nil, nil)
end

.proc(pr = nil, &block) ⇒ Object



728
729
730
731
732
733
# File 'lib/racc/grammar.rb', line 728

def UserAction.proc(pr = nil, &block)
  if pr and block
    raise ArgumentError, "both of argument and block given"
  end
  new(nil, pr || block)
end

.source_text(src) ⇒ Object



724
725
726
# File 'lib/racc/grammar.rb', line 724

def UserAction.source_text(src)
  new(src, nil)
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


757
758
759
# File 'lib/racc/grammar.rb', line 757

def empty?
  not @proc and not @source
end

#nameObject Also known as: inspect



761
762
763
# File 'lib/racc/grammar.rb', line 761

def name
  "{action type=#{@source || @proc || 'nil'}}"
end

#proc?Boolean

Returns:

  • (Boolean)


753
754
755
# File 'lib/racc/grammar.rb', line 753

def proc?
  not @source
end

#source?Boolean

Returns:

  • (Boolean)


749
750
751
# File 'lib/racc/grammar.rb', line 749

def source?
  not @proc
end