Class: Nasl::Expression

Inherits:
Node
  • Object
show all
Defined in:
lib/nasl/parser/expression.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#ctx, #tokens

Instance Method Summary collapse

Methods inherited from Node

#context, #region, #to_xml

Constructor Details

#initialize(tree, *tokens) ⇒ Expression

Returns a new instance of Expression.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/nasl/parser/expression.rb', line 33

def initialize(tree, *tokens)
  super

  @children << :op

  if @tokens.first.is_a?(Token) && @tokens.first.type == :LPAREN
    @op = '()'
    @lhs = nil
    @rhs = @tokens[1]
  elsif @tokens.length == 2
    @op = @tokens.first
    @lhs = nil
    @rhs = @tokens.last
  else
    @children << :lhs
    @lhs = @tokens[0]
    @op = @tokens[1]
    @rhs = @tokens[2]
  end

  @children << :rhs
end

Instance Attribute Details

#lhsObject (readonly)

Returns the value of attribute lhs.



31
32
33
# File 'lib/nasl/parser/expression.rb', line 31

def lhs
  @lhs
end

#opObject (readonly)

Returns the value of attribute op.



31
32
33
# File 'lib/nasl/parser/expression.rb', line 31

def op
  @op
end

#rhsObject (readonly)

Returns the value of attribute rhs.



31
32
33
# File 'lib/nasl/parser/expression.rb', line 31

def rhs
  @rhs
end