Class: RedParse::MultiShift
- Inherits:
-
Object
- Object
- RedParse::MultiShift
- Defined in:
- lib/redparse/compile.rb,
lib/redparse/compile.rb
Instance Attribute Summary collapse
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#modifiers ⇒ Object
readonly
Returns the value of attribute modifiers.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #act(x) ⇒ Object
- #actions ⇒ Object
- #hash ⇒ Object
-
#initialize(base, modifiers) ⇒ MultiShift
constructor
A new instance of MultiShift.
- #substates ⇒ Object
-
#transition_to_loop?(input) ⇒ Boolean
not used.
Constructor Details
#initialize(base, modifiers) ⇒ MultiShift
Returns a new instance of MultiShift.
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 |
# File 'lib/redparse/compile.rb', line 1064 def initialize(base,modifiers) @base,@modifiers=base,modifiers @map= (0...2**(modifiers.size/2)).map{|i| base.dup} @map.each_with_index{|state,i| #for each branch to the multishift (0...modifiers.size).step(2){|j| #for each predicate in the multishift if (i&(1<<j)).non_zero? #if the predicate tests true in this branch state.append modifiers[j+1] #add the predicates modifier to the state end } state.sort_substates! } end |
Instance Attribute Details
#map ⇒ Object (readonly)
Returns the value of attribute map.
1086 1087 1088 |
# File 'lib/redparse/compile.rb', line 1086 def map @map end |
#modifiers ⇒ Object (readonly)
Returns the value of attribute modifiers.
1086 1087 1088 |
# File 'lib/redparse/compile.rb', line 1086 def modifiers @modifiers end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
1103 1104 1105 |
# File 'lib/redparse/compile.rb', line 1103 def == other huh end |
#act(x) ⇒ Object
1078 1079 1080 1081 1082 1083 1084 |
# File 'lib/redparse/compile.rb', line 1078 def act(x) result=0 (0...@modifiers.size).step(2){|i| result|=(1<<(i/2)) if @modifiers[i]===x } @map[result] end |
#actions ⇒ Object
1092 1093 1094 |
# File 'lib/redparse/compile.rb', line 1092 def actions @map.dup end |
#hash ⇒ Object
1100 1101 1102 |
# File 'lib/redparse/compile.rb', line 1100 def hash huh end |
#substates ⇒ Object
1088 1089 1090 |
# File 'lib/redparse/compile.rb', line 1088 def substates @map.dup end |
#transition_to_loop?(input) ⇒ Boolean
not used
1096 1097 1098 |
# File 'lib/redparse/compile.rb', line 1096 def transition_to_loop? input #not used huh end |