class

Marpa::Parser

Inherits Reference < Object

Constructors

Instance methods

build_meta_grammar(actions)
Source
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"]
Source
discard
Source
discard=(discard : Array(String))
Source
discards
Source
discards=(discards : Array(Tuple(String, String)))
Source
expected
Source
expected=(expected : Array(String))
Source
grammar
Source
grammar=(grammar : LibMarpa::MarpaGrammar)
Source
input
Source
input=(input : String)
Source
lexemes
Source
lexemes=(lexemes : Hash(Int32, Hash(String, String)))
Source
lexer
Source
lexer=(lexer : Hash(String, Regex))
Source
matches
Source
matches=(matches : Array(Tuple(String, String)))
Source
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

Source
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

Source
position
Source
position=(position : Int32)
Source
recce
Source
recce=(recce : LibMarpa::MarpaRecognizer)
Source
rules
Source
rules=(rules : Hash(Int32, Hash(String, String)))
Source
symbols
Source
symbols=(symbols : Hash(String, Int32))
Source
values
Source
values=(values : Hash(Int32, String))
Source

Nested types