### Home Classes Methods

### In Files

- lib/gherkin/parser/parser.rb

### Parent

Object

### Namespace

- CLASS Gherkin::Parser::Parser::Machine

### Methods

- ::new
- #event
- #expected
- #force_state
- #location
- #machine
- #method_missing
- #pop_machine
- #push_machine

### Files

- LICENSE
- README.rdoc
- meta.txt
- root.txt
- steps.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Gherkin
- Gherkin::CLexer
- Gherkin::Cli
- Gherkin::Cli::Main
- Gherkin::Formatter
- Gherkin::Formatter::Argument
- Gherkin::Formatter::Colors
- Gherkin::Formatter::Escaping
- Gherkin::Formatter::JSONFormatter
- Gherkin::Formatter::MonochromeFormat
- Gherkin::Formatter::PrettyFormatter
- Gherkin::I18n
- Gherkin::I18nLexer
- Gherkin::JSONLexer
- Gherkin::Parser
- Gherkin::Parser::Event
- Gherkin::Parser::FilterListener
- Gherkin::Parser::FormatterListener
- Gherkin::Parser::ParseError
- Gherkin::Parser::Parser
- Gherkin::Parser::Parser::Machine
- Gherkin::Parser::Parser::Machine::StateMachineReader
- Gherkin::Parser::Row
- Gherkin::Parser::TagExpression
- Gherkin::RbLexer
- Gherkin::Rubify
- Gherkin::Tools
- Gherkin::Tools::Files
- Gherkin::Tools::Reformat
- Gherkin::Tools::Stats
- Gherkin::Tools::StatsListener
- Class

No matching classes.

# Gherkin::Parser::Parser

### Public Class Methods

new(listener, raise_on_error=true, machine_name='root') click to toggle source

Initialize the parser. `machine_name` refers to a state machine table.

    # File lib/gherkin/parser/parser.rb, line 15
    def initialize(listener, raise_on_error=true, machine_name='root')
      @listener = listener
      @raise_on_error = raise_on_error
      @machines = []
      @machine_name = machine_name
      push_machine(@machine_name)
    end

### Public Instance Methods

event(ev, line) click to toggle source

    # File lib/gherkin/parser/parser.rb, line 39
    def event(ev, line)
      machine.event(ev, line) do |state, expected|
        if @raise_on_error
          raise ParseError.new(state, ev, expected, line)
        else
          @listener.syntax_error(state, ev, expected, line)
          return false
        end
      end
      true
    end

expected() click to toggle source

    # File lib/gherkin/parser/parser.rb, line 63
    def expected
      machine.expected
    end

force_state(state) click to toggle source

    # File lib/gherkin/parser/parser.rb, line 67
    def force_state(state)
      machine.instance_variable_set('@state', state)
    end

location(uri, offset) click to toggle source

    # File lib/gherkin/parser/parser.rb, line 23
    def location(uri, offset)
      @listener.location(uri, offset)
    end

machine() click to toggle source

    # File lib/gherkin/parser/parser.rb, line 59
    def machine
      @machines[-1]
    end

method_missing(method, *args) click to toggle source

Doesn’t yet fall back to super

    # File lib/gherkin/parser/parser.rb, line 28
    def method_missing(method, *args)
      # TODO: Catch exception and call super
      if(event(method.to_s, args[-1]))
        @listener.__send__(method, *args)
      end
      if method == :eof
        pop_machine
        push_machine(@machine_name)
      end
    end

pop_machine() click to toggle source

    # File lib/gherkin/parser/parser.rb, line 55
    def pop_machine
      @machines.pop
    end

push_machine(name) click to toggle source

    # File lib/gherkin/parser/parser.rb, line 51
    def push_machine(name)
      @machines.push(Machine.new(self, name))
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.