Class: Chelsy::Macro

Inherits:
Expr show all
Defined in:
lib/chelsy/ast.rb

Overview

AST node represents a macro invocation with or without arguments.

Instance Attribute Summary collapse

Attributes inherited from Element

#fragments, #post_fragments

Instance Method Summary collapse

Constructor Details

#initialize(name, args = nil, **rest) ⇒ Macro

initialize instance.

Parameters:

  • name (Symbol)

    Macro name

  • args (Enumerable) (defaults to: nil)

    Arguments. nil if no arguments supplied.



1167
1168
1169
1170
1171
1172
# File 'lib/chelsy/ast.rb', line 1167

def initialize(name, args=nil, **rest)
  @name = Syntax::Ident.ensure(name)
  @args = args.map {|a| Syntax::Expr.ensure(a) } if args

  super **rest
end

Instance Attribute Details

#argsEnumerable (readonly)

Returns Arguments.

Returns:

  • (Enumerable)

    Arguments



1158
1159
1160
# File 'lib/chelsy/ast.rb', line 1158

def args
  @args
end

#nameSymbol (readonly)

Returns Macro name.

Returns:

  • (Symbol)

    Macro name



1158
1159
1160
# File 'lib/chelsy/ast.rb', line 1158

def name
  @name
end