class CLTK::CFG

Overview

The CFG class is used to represent context-free grammars. It is used by the CLTK::Parser class to represent the parser's grammar, but can also be used to manipulate arbitrary CFGs.

Defined in:

cltk/cfg/production.cr
cltk/cfg/item.cr
cltk/cfg.cr
cltk/parser/msgpack.cr

Class Method Summary

Instance Method Summary

Instance methods inherited from class Object

in?(collection : Array | Set) in?

Class Method Detail

def self.is_nonterminal?(sym) #

[View source]
def self.is_terminal?(sym) #

[View source]

Instance Method Detail

def add_production(production) #

Adds production to the appropriate internal data structures.

@param [Production] production The production to add to the grammar.

@return [void]


[View source]
def build_list_production(name : String, list_elements : String | Array(String), separator = "") #

[View source]
def build_nonempty_list_production(name : String, list_elements : String | Array(String), separator = "") #

[View source]
def build_optional_production(name : String, opt_symbol : String) #

[View source]
def callback(&callback : Symbol, Symbol, Production, Array(Int32) -> Nil) #

[View source]
def clause(expression : Symbol | String) #

[View source]
def curr_lhs : String? #

[View source]
def curr_lhs=(curr_lhs) #

[View source]
def first_set(sentence : String | Array(String)) : Array(String) #

[View source]
def follow_set(sym0 : String, seen_lh_sides = [] of String) : Array(String) #

[View source]
def get_list_production(name, list_elements : String | Array(String), separator = "") #

[View source]
def get_nonempty_list_production(name : String, list_elements : String | Array(String), separator = "") #

[View source]
def get_optional_production(name : String, list_elements : String | Array(String)) #

[View source]
def next_id #

@return [Integer] ID for the next production to be defined.


[View source]
def nonterms #

[View source]
def production(symbol : Symbol | String, expression : String? = nil) #

[View source]
def production(symbol : Symbol | String, expression : String? = nil, &block) #

[View source]
def productions_id : Hash(Int32, CLTK::CFG::Production) #

[View source]
def productions_sym : Hash(String, Array(CLTK::CFG::Production)) #

[View source]
def start_symbol : String #

[View source]
def symbols #

@return [Array<Symbol>] All symbols used in the grammar's definition.


[View source]
def terms #

[View source]
def with_curr_lhs(symbol, &block) #

[View source]