class
GrammarContext
local gc = Grammar.context()
-- Register live schema
gc:learn_enum("status", { "pending", "active", "closed" })
gc:learn_table("users", { "id", "name", "email" })
-- Compile current grammar (cached until invalidated)
local g = gc:current()
-- Grammar grows with the conversation
gc:learn_table("orders", { "id", "user_id", "total" })
-- Branch and restore
local snap = gc:snapshot()
gc:learn_enum("color", { "red", "blue" })
gc:restore(snap) -- back to before color
Functions
GrammarContext.new
GrammarContext:_invalidate
GrammarContext:learn_enum
GrammarContext:learn_table
GrammarContext:learn_tool
GrammarContext:learn_rule
GrammarContext:forget
GrammarContext:current
GrammarContext:snapshot
GrammarContext:restore
GrammarContext:stats
GrammarContext.new
Create a new GrammarContext.
GrammarContext.new(opts)
optstable?
→ GrammarContext
GrammarContext:_invalidate
GrammarContext:_invalidate()
GrammarContext:learn_enum
Register an enum whitelist (creates or replaces a named rule).
GrammarContext:learn_enum(rule_name, values)
rule_namestringRule name.
valuestableArray of allowed string values.
→ GrammarContextself
GrammarContext:learn_table
Register a database table with its column names. Creates two rules: `