Class: RedParse::MultiReduce
- Inherits:
-
Object
- Object
- RedParse::MultiReduce
- Defined in:
- lib/redparse/compile.rb,
lib/redparse/compile.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #act(x) ⇒ Object
- #actions ⇒ Object
- #hash ⇒ Object
-
#initialize(list, default) ⇒ MultiReduce
constructor
A new instance of MultiReduce.
- #substates ⇒ Object
-
#transition_to_loop?(input) ⇒ Boolean
not used.
Constructor Details
#initialize(list, default) ⇒ MultiReduce
Returns a new instance of MultiReduce.
922 923 924 925 |
# File 'lib/redparse/compile.rb', line 922 def initialize(list,default) @list,@default=list,default #default can be any valid action (except another MultiReduce) end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
927 928 929 |
# File 'lib/redparse/compile.rb', line 927 def default @default end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
927 928 929 |
# File 'lib/redparse/compile.rb', line 927 def list @list end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
965 966 967 |
# File 'lib/redparse/compile.rb', line 965 def == other @list==other.list and @default==other.default end |
#act(x) ⇒ Object
929 930 931 932 933 934 |
# File 'lib/redparse/compile.rb', line 929 def act(x) (0...@list.size).step(2){|i| return @list[i+1] if @list[i]===x } return default end |
#actions ⇒ Object
944 945 946 947 948 949 950 951 952 953 954 955 |
# File 'lib/redparse/compile.rb', line 944 def actions result=[] (1...@list.size).step(2){|i| result << @list[i] } if @default.respond_to? :actions result.concat @default.actions elsif @default result<<@default end result end |
#hash ⇒ Object
961 962 963 |
# File 'lib/redparse/compile.rb', line 961 def hash @list.hash^~@default.hash end |
#substates ⇒ Object
936 937 938 939 940 941 942 |
# File 'lib/redparse/compile.rb', line 936 def substates if @default.respond_to? :substates @default.substates else [] end end |
#transition_to_loop?(input) ⇒ Boolean
not used
957 958 959 |
# File 'lib/redparse/compile.rb', line 957 def transition_to_loop? input #not used @default.transition_to_loop? input end |