Sha256: 1eadf202ee01460a0a6b8ba5f69e0a5fd0d5cbfe2718f084890c05149a4933d9

Contents?: true

Size: 1.95 KB

Versions: 2

Compression:

Stored size: 1.95 KB

Contents

module LucidTDL
  module AST
    class Node
      attr_reader :filename, :line
      
      def accept(visitor)
        name = self.class.name.split('::').last
        visitor.send("visit_#{name}".to_sym, self)
      end
      
      def pos(filename, line=nil)
        @filename = filename
        @line = line
      end
      
    end # class Node
    
    class Feature < Node
      include Enumerable
      
      attr_reader :name
      attr_accessor :description, :background, :scenarios, :tags
      
      def initialize(name, scenarios=[], tags=[], background=nil)
        @name = name
        @background = background
        @scenarios = scenarios
        @tags = tags
      end
      
      def each
        @scenarios.each
      end
    end # class Feature
    
    class Ability < Feature
    end
    
    class Responsibility < Feature
    end
    
    class Background < Node
      include Enumerable
      
      attr_accessor :steps
      
      def initialize(steps=[])
        @steps = steps
      end
      
      def line
        @steps.first.line - 1 if @steps.any?
      end
      
      def each
        @steps.each
      end
    end # class Background
    
    class Scenario < Node
      include Enumerable
      
      attr_reader :name, :steps, :tags
      
      def initialize(name, steps=[], tags=[])
        @name = name.to_s
        @steps = steps
        @tags = tags
      end
      
      def line
        @steps.first.line - 1 if @steps.any?
      end
      
      def each
        @steps.each
      end
    end # class Scenario
    
    class Test < Scenario
    end
    
    class Step < Node
      attr_reader :name
      attr_reader :keyword
      
      def initialize(name, keyword)
        @name = name.to_s
        @keyword = keyword.to_s
      end
    end # class Step
    
    class Tag < Node
      attr_reader :name
      
      def initialize(name)
        @name = name
      end
    end # class Tag
    
  end # module AST
end # module LucidTDL

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lucid-tdl-1.1.0 lib/lucid-tdl/ast.rb
lucid-tdl-1.0.0 lib/lucid-tdl/ast.rb