Class: ActionDispatch::Journey::Parser
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Nodes
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/journey/parser.rb |
Class Method Summary
- .new ⇒ Parser constructor
- .parse(string)
Instance Method Summary
- #parse(string)
- #advance_token private
- #do_parse private
- #parse_expression private
- #parse_expressions private
- #parse_group private
- #parse_or(lhs) private
- #parse_star private
- #parse_terminal private
Constructor Details
.new ⇒ Parser
Class Method Details
.parse(string)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 11
def self.parse(string) new.parse string end
Instance Method Details
#advance_token (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 27
def advance_token @next_token = @scanner.next_token end
#do_parse (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 31
def do_parse parse_expressions end
#parse(string)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 20
def parse(string) @scanner.scan_setup(string) advance_token do_parse end
#parse_expression (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 58
def parse_expression if @next_token == :STAR parse_star elsif @next_token == :LPAREN parse_group else parse_terminal end end
#parse_expressions (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 35
def parse_expressions node = parse_expression while @next_token case @next_token when :RPAREN break when :OR node = parse_or(node) else node = Cat.new(node, parse_expressions) end end node end
#parse_group (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 74
def parse_group advance_token node = parse_expressions if @next_token == :RPAREN node = Group.new(node) advance_token node else raise ArgumentError, "missing right parenthesis." end end
#parse_or(lhs) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 52
def parse_or(lhs) advance_token node = parse_expression Or.new([lhs, node]) end
#parse_star (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/parser.rb', line 68
def parse_star node = Star.new(Symbol.new(@scanner.last_string, Symbol::GREEDY_EXP)) advance_token node end