class Crowbar::GrammarBuilder

Overview

DSL builder for defining context-free grammars

Defined in:

crowbar/dsl/grammar_builder.cr

Constructors

Instance Method Summary

Constructor Detail

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

Instance Method Detail

def choices(name : Symbol, options : Iterable(String), weight : Float64 = 1.0) #

Convenience overload for list of terminal string options (shorthand for single-token choices)


def grammar : GrammarDefinition #

def max_depth(val : Int32) #

def rule(name : Symbol, tokens : Iterable(String | Symbol), weight : Float64 = 1.0) #

Define a production rule with an array of tokens and optional weight


def rule(name : Symbol, *tokens : String | Symbol, weight : Float64 = 1.0) #

Convenience overload for passing multiple string/symbol arguments