class Marpa::Parser

Defined in:

marpa.cr
marpa/helpers.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

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 discard : Array(String) #

[View source]
def discard=(discard : Array(String)) #

[View source]
def discards : Array({String, String}) #

[View source]
def discards=(discards : Array(Tuple(String, String))) #

[View source]
def expected : Array(String) #

[View source]
def expected=(expected : Array(String)) #

[View source]
def grammar : LibMarpa::MarpaGrammar #

[View source]
def grammar=(grammar : LibMarpa::MarpaGrammar) #

[View source]
def input : String #

[View source]
def input=(input : String) #

[View source]
def lexemes : Hash(Int32, Hash(String, String)) #

[View source]
def lexemes=(lexemes : Hash(Int32, Hash(String, String))) #

[View source]
def lexer : Hash(String, Regex) #

[View source]
def lexer=(lexer : Hash(String, Regex)) #

[View source]
def matches : Array({String, String}) #

[View source]
def matches=(matches : Array(Tuple(String, String))) #

[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]
def position : Int32 #

[View source]
def position=(position : Int32) #

[View source]
def recce : LibMarpa::MarpaRecognizer #

[View source]
def recce=(recce : LibMarpa::MarpaRecognizer) #

[View source]
def rules : Hash(Int32, Hash(String, String)) #

[View source]
def rules=(rules : Hash(Int32, Hash(String, String))) #

[View source]
def symbols : Hash(String, Int32) #

[View source]
def symbols=(symbols : Hash(String, Int32)) #

[View source]
def values : Hash(Int32, String) #

[View source]
def values=(values : Hash(Int32, String)) #

[View source]