class Nasl::Function

Attributes

attribute[R]
body[R]
fn_type[R]
name[R]
params[R]

Public Class Methods

new(tree, *tokens) click to toggle source
Calls superclass method
# File lib/nasl/parser/function.rb, line 33
def initialize(tree, *tokens)
  super

  @body = @tokens.last
  @fn_type = @tokens[1]

  if @fn_type == "obj"
    if @tokens.length == 8 
      @name = @tokens[3]
      @attribute = @tokens[0]
      @params = @tokens[5]          
    elsif @tokens.length == 7
      if @tokens[0].is_a?(Token) && @tokens[0].type == :FUNCTION
        @attribute = nil
        @params = @tokens[4]
        @name = @tokens[2]
      else
        @name = @tokens[3]
        @attribute = @tokens[0]
        @params = []
      end
    elsif @tokens.length == 6
      @attribute = nil
      @params = []
      @name = @tokens[2]
    end
  else
    @name = @tokens[2]
    @attribute = []
    if @tokens.length == 7
      @params = @tokens[4]
    else
      @params = []
    end
  end

  @children << :name
  @children << :attribute
  @children << :params
  @children << :body
  @children << :fn_type
end

Public Instance Methods

each() { |stmt| ... } click to toggle source
# File lib/nasl/parser/function.rb, line 76
def each
  @body.each{ |stmt| yield stmt }
end