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.
972 973 974 975 976 977 978 979 980 981 982 983 984 |
# File 'lib/redparse/compile.rb', line 972 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.
994 995 996 |
# File 'lib/redparse/compile.rb', line 994 def map @map end |
#modifiers ⇒ Object (readonly)
Returns the value of attribute modifiers.
994 995 996 |
# File 'lib/redparse/compile.rb', line 994 def modifiers @modifiers end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
1011 1012 1013 |
# File 'lib/redparse/compile.rb', line 1011 def == other huh end |
#act(x) ⇒ Object
986 987 988 989 990 991 992 |
# File 'lib/redparse/compile.rb', line 986 def act(x) result=0 (0...@modifiers.size).step(2){|i| result|=(1<<(i/2)) if @modifiers[i]===x } @map[result] end |
#actions ⇒ Object
1000 1001 1002 |
# File 'lib/redparse/compile.rb', line 1000 def actions @map.dup end |
#hash ⇒ Object
1008 1009 1010 |
# File 'lib/redparse/compile.rb', line 1008 def hash huh end |
#substates ⇒ Object
996 997 998 |
# File 'lib/redparse/compile.rb', line 996 def substates @map.dup end |
#transition_to_loop?(input) ⇒ Boolean
not used
1004 1005 1006 |
# File 'lib/redparse/compile.rb', line 1004 def transition_to_loop? input #not used huh end |