Class: Mlc::ParserState
- Inherits:
-
Object
- Object
- Mlc::ParserState
- Defined in:
- lib/mlc/parserstate.rb
Instance Attribute Summary collapse
-
#lvars ⇒ Object
readonly
Returns the value of attribute lvars.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #add_lvar(name) ⇒ Object
-
#initialize(parent = nil, inherit = true) ⇒ ParserState
constructor
A new instance of ParserState.
- #knows_lvar?(name) ⇒ Boolean
- #lvars_define ⇒ Object
- #tmpvar ⇒ Object
Constructor Details
#initialize(parent = nil, inherit = true) ⇒ ParserState
Returns a new instance of ParserState.
6 7 8 9 10 11 |
# File 'lib/mlc/parserstate.rb', line 6 def initialize(parent = nil, inherit = true) @tmpid = -1 @lvars = [] @parent = parent @inherit = inherit end |
Instance Attribute Details
#lvars ⇒ Object (readonly)
Returns the value of attribute lvars.
4 5 6 |
# File 'lib/mlc/parserstate.rb', line 4 def lvars @lvars end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/mlc/parserstate.rb', line 4 def parent @parent end |
Instance Method Details
#add_lvar(name) ⇒ Object
17 18 19 20 21 |
# File 'lib/mlc/parserstate.rb', line 17 def add_lvar(name) unless knows_lvar? name @lvars << name end end |
#knows_lvar?(name) ⇒ Boolean
23 24 25 |
# File 'lib/mlc/parserstate.rb', line 23 def knows_lvar?(name) @lvars.include? name || (@inherit && @parent && @parent.knows_lvar?(name)) end |
#lvars_define ⇒ Object
27 28 29 |
# File 'lib/mlc/parserstate.rb', line 27 def lvars_define @lvars.map{|el| 'l' + el.to_s}.join(', ') end |
#tmpvar ⇒ Object
13 14 15 |
# File 'lib/mlc/parserstate.rb', line 13 def tmpvar "__tmp_#{@tmpid += 1}" end |