class Crowbar::GrammarDefinition

Overview

Context-free generative grammar engine with bounded recursion depth.

Defined in:

crowbar/dsl/grammar_builder.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, max_depth : Int32 = 8) #

Instance Method Detail

def add_production(rule_name : Symbol, tokens : Iterable(String | Symbol), weight : Float64 = 1.0) #

Adds a production for a non-terminal rule


def generate(start_symbol : Symbol = :start, prng : PRNG = PRNG.new) : String #

Generates a string starting from start_symbol


def max_depth : Int32 #

def max_depth=(max_depth : Int32) #

def name : String #

def rules : Hash(Symbol, Array(Production)) #