Class: Prattle::AST::ArrayLiteral
- Inherits:
-
Node
- Object
- Node
- Prattle::AST::ArrayLiteral
- Defined in:
- lib/prattle/ast/array_literal.rb
Instance Attribute Summary (collapse)
-
- (Object) elements
readonly
Returns the value of attribute elements.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) bytecode(g)
-
- (ArrayLiteral) initialize(elements)
constructor
A new instance of ArrayLiteral.
Methods inherited from Node
Constructor Details
- (ArrayLiteral) initialize(elements)
A new instance of ArrayLiteral
10 11 12 |
# File 'lib/prattle/ast/array_literal.rb', line 10 def initialize(elements) @elements = elements end |
Instance Attribute Details
- (Object) elements (readonly)
Returns the value of attribute elements
14 15 16 |
# File 'lib/prattle/ast/array_literal.rb', line 14 def elements @elements end |
Class Method Details
+ (Object) grammar(g)
16 17 18 19 20 |
# File 'lib/prattle/ast/array_literal.rb', line 16 def self.grammar(g) g.array_literal = g.seq("{", :sp, g.t(:expressions), :sp, "}") { |e| ArrayLiteral.new(e) } end |
+ (Object) rule_name
6 7 8 |
# File 'lib/prattle/ast/array_literal.rb', line 6 def self.rule_name "array" end |
Instance Method Details
- (Object) bytecode(g)
22 23 24 25 26 27 28 |
# File 'lib/prattle/ast/array_literal.rb', line 22 def bytecode(g) @elements.each do |e| e.bytecode(g) end g.make_array @elements.size end |