Class: RedParse::StackMonkey
- Inherits:
-
Object
- Object
- RedParse::StackMonkey
- Defined in:
- lib/redparse.rb
Overview
include Nodes
Direct Known Subclasses
Instance Attribute Summary collapse
-
#and_expect_node ⇒ Object
(also: #hint)
readonly
Returns the value of attribute and_expect_node.
-
#exemplars ⇒ Object
Returns the value of attribute exemplars.
-
#first_changed_index ⇒ Object
readonly
Returns the value of attribute first_changed_index.
-
#monkey_code ⇒ Object
readonly
Returns the value of attribute monkey_code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #[](stack) ⇒ Object
- #_dump(depth) ⇒ Object
- #action2c ⇒ Object
-
#initialize(name, first_changed_index, and_expect_node, options = {}, &monkey_code) ⇒ StackMonkey
constructor
A new instance of StackMonkey.
Constructor Details
#initialize(name, first_changed_index, and_expect_node, options = {}, &monkey_code) ⇒ StackMonkey
46 47 48 49 50 |
# File 'lib/redparse.rb', line 46 def initialize(name,first_changed_index,and_expect_node,={},&monkey_code) first_changed_index=-first_changed_index if first_changed_index>0 @name,@first_changed_index,@and_expect_node,@monkey_code= name,first_changed_index,and_expect_node,monkey_code end |
Instance Attribute Details
#and_expect_node ⇒ Object (readonly) Also known as: hint
Returns the value of attribute and_expect_node.
52 53 54 |
# File 'lib/redparse.rb', line 52 def and_expect_node @and_expect_node end |
#exemplars ⇒ Object
Returns the value of attribute exemplars.
54 55 56 |
# File 'lib/redparse.rb', line 54 def exemplars @exemplars end |
#first_changed_index ⇒ Object (readonly)
Returns the value of attribute first_changed_index.
52 53 54 |
# File 'lib/redparse.rb', line 52 def first_changed_index @first_changed_index end |
#monkey_code ⇒ Object (readonly)
Returns the value of attribute monkey_code.
52 53 54 |
# File 'lib/redparse.rb', line 52 def monkey_code @monkey_code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
52 53 54 |
# File 'lib/redparse.rb', line 52 def name @name end |
Class Method Details
._load(str) ⇒ Object
65 66 67 |
# File 'lib/redparse.rb', line 65 def self._load str Thread.current[:$RedParse_parser].undumpables[@name] end |
Instance Method Details
#[](stack) ⇒ Object
56 57 58 59 |
# File 'lib/redparse.rb', line 56 def [](stack) result=@monkey_code[stack] return result end |
#_dump(depth) ⇒ Object
61 62 63 |
# File 'lib/redparse.rb', line 61 def _dump depth @name end |
#action2c ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/redparse.rb', line 69 def action2c #"return the whole thing on first call, just a goto stmt after that" return " goto #@goto_label;\n" if defined? @goto_label =begin <<-E #{@[email protected](/[^a-z0-9_]/,'_')}: monkey=rb_hash_get(undumpables,rb_cstr2str("#@name")); rb_funcall(monkey,rb_intern("[]"),huh_stack); /*recover from stackmonkey fiddling*/ for(i=0;i<#{-@first_changed_index};++i) { rb_ary_unshift(lexer_moretokens, rb_ary_pop(huh_semantic_stack)); rb_ary_pop(huh_syntax_stack); } goto #{Node===@and_expect_node ? postreduceaction4this_state(@and_expect_node) : shiftaction4this_state }; E =end end |