class Marpa::Parser

Defined in:

marpa.cr
marpa/helpers.cr

Instance Method Summary

Instance Method Detail

def build_meta_grammar(actions) #

[View source]
def compile(grammar : String) #

Convenience method to expose internals of grammar, lexer, symbols, rules, etc. Accepts grammar as BNF, and returns a builder object that can be used the same as before:

parser = Marpa::Parser.new
grammar = <<-'END_BNF'
:start ::= A
A ::= a
a ~ 'a'
END_BNF
input = "a"
grammar = parser.compile(grammar)
parser.parse(input, grammar) # => ["a"]

[View source]
def parse(input : String, grammar : String, actions : Actions = Actions.new, events : Events = Events.new) #

Parse input given grammar in BNF format. Accepts optional actions that can be used to perform semantics on given rules. On successful parse, returns the parse tree


[View source]
def parse(input : String, builder : Builder, actions : Actions = Actions.new, events : Events = Events.new) #

Internal method used to parse the given input given computed grammar, Notated here as builder


[View source]