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.crcltk/cfg/item.cr
cltk/cfg.cr
cltk/parser/msgpack.cr
Class Method Summary
Instance Method Summary
-
#add_production(production)
Adds production to the appropriate internal data structures.
- #build_list_production(name : String, list_elements : String | Array(String), separator = "")
- #build_nonempty_list_production(name : String, list_elements : String | Array(String), separator = "")
- #build_optional_production(name : String, opt_symbol : String)
- #callback(&callback : Symbol, Symbol, Production, Array(Int32) -> Nil)
- #clause(expression : Symbol | String)
- #curr_lhs : String?
- #curr_lhs=(curr_lhs)
- #first_set(sentence : String | Array(String)) : Array(String)
- #follow_set(sym0 : String, seen_lh_sides = [] of String) : Array(String)
- #get_list_production(name, list_elements : String | Array(String), separator = "")
- #get_nonempty_list_production(name : String, list_elements : String | Array(String), separator = "")
- #get_optional_production(name : String, list_elements : String | Array(String))
-
#next_id
@return [Integer] ID for the next production to be defined.
- #nonterms
- #production(symbol : Symbol | String, expression : String? = nil)
- #production(symbol : Symbol | String, expression : String? = nil, &block)
- #productions_id : Hash(Int32, CLTK::CFG::Production)
- #productions_sym : Hash(String, Array(CLTK::CFG::Production))
- #start_symbol : String
-
#symbols
@return [Array<Symbol>] All symbols used in the grammar's definition.
- #terms
- #with_curr_lhs(symbol, &block)
Instance methods inherited from class Object
in?(collection : Array | Set)
in?
Class Method Detail
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]
def build_list_production(name : String, list_elements : String | Array(String), separator = "")
#
def build_nonempty_list_production(name : String, list_elements : String | Array(String), separator = "")
#
def get_list_production(name, list_elements : String | Array(String), separator = "")
#
def get_nonempty_list_production(name : String, list_elements : String | Array(String), separator = "")
#