Parent

Gherkin::Parser::Parser

Public Class Methods

new(formatter, raise_on_error=true, machine_name='root', force_ruby=false) click to toggle source

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

    # File lib/gherkin/parser/parser.rb, line 18
18:       def initialize(formatter, raise_on_error=true, machine_name='root', force_ruby=false)
19:         @formatter = formatter
20:         @listener = Listener::FormatterListener.new(@formatter)
21:         @raise_on_error = raise_on_error
22:         @machine_name = machine_name
23:         @machines = []
24:         push_machine(@machine_name)
25:         @lexer = Gherkin::Lexer::I18nLexer.new(self, force_ruby)
26:       end

Public Instance Methods

errors() click to toggle source
    # File lib/gherkin/parser/parser.rb, line 38
38:       def errors
39:         @lexer.errors
40:       end
event(ev, line) click to toggle source
    # File lib/gherkin/parser/parser.rb, line 53
53:       def event(ev, line)
54:         l = line ? @line_offset+line : nil
55:         machine.event(ev, l) do |state, legal_events|
56:           if @raise_on_error
57:             raise ParseError.new(state, ev, legal_events, @feature_uri, l)
58:           else
59:             # Only used for testing
60:             @listener.syntax_error(state, ev, legal_events, @feature_uri, l)
61:           end
62:         end
63:       end
expected() click to toggle source
    # File lib/gherkin/parser/parser.rb, line 77
77:       def expected
78:         machine.expected
79:       end
force_state(state) click to toggle source
    # File lib/gherkin/parser/parser.rb, line 81
81:       def force_state(state)
82:         machine.instance_variable_set('@state', state)
83:       end
i18n_language() click to toggle source
    # File lib/gherkin/parser/parser.rb, line 34
34:       def i18n_language
35:         @lexer.i18n_language
36:       end
machine() click to toggle source
    # File lib/gherkin/parser/parser.rb, line 73
73:       def machine
74:         @machines[1]
75:       end
method_missing(method, *args) click to toggle source

Doesn’t yet fall back to super

    # File lib/gherkin/parser/parser.rb, line 43
43:       def method_missing(method, *args)
44:         # TODO: Catch exception and call super
45:         event(method.to_s, args[1])
46:         @listener.__send__(method, *args)
47:         if method == :eof
48:           pop_machine
49:           push_machine(@machine_name)
50:         end
51:       end
parse(gherkin, feature_uri, line_offset) click to toggle source
    # File lib/gherkin/parser/parser.rb, line 28
28:       def parse(gherkin, feature_uri, line_offset)
29:         @formatter.uri(feature_uri)
30:         @line_offset = line_offset
31:         @lexer.scan(gherkin)
32:       end
pop_machine() click to toggle source
    # File lib/gherkin/parser/parser.rb, line 69
69:       def pop_machine
70:         @machines.pop
71:       end
push_machine(name) click to toggle source
    # File lib/gherkin/parser/parser.rb, line 65
65:       def push_machine(name)
66:         @machines.push(Machine.new(self, name))
67:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.