Documentation
¶
Overview ¶
Package grammar extracts lexical vocabulary from the grammars of the parsers gomplate actually runs, so the editor tokenizers stay in step with them instead of being transcribed by hand.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CELGrammarSource ¶
func CELGrammarSource() string
CELGrammarSource returns the vendored grammar text.
Types ¶
type CELGrammar ¶
type CELGrammar struct {
// Operators are the punctuation tokens, ordered longest-first so a
// tokenizer trying them in sequence never lets `<` shadow `<=`.
Operators []string
// Keywords are the literal word tokens: in, true, false, null.
Keywords []string
// Patterns maps a composite token rule (STRING, NUM_INT, IDENTIFIER, ...)
// to JS regex source.
Patterns map[string]string
}
CELGrammar is the lexical vocabulary of CEL, extracted from CEL.g4.
func ParseCEL ¶
func ParseCEL() (*CELGrammar, error)
ParseCEL extracts the lexical vocabulary from the vendored CEL.g4.
type GoTemplateGrammar ¶
type GoTemplateGrammar struct {
// Keywords are the action keywords: if, range, end, ...
Keywords []string
// Builtins are the functions text/template supplies itself.
Builtins []string
// LeftDelim and RightDelim open and close an action.
LeftDelim, RightDelim string
// LeftComment and RightComment open and close a comment inside an action.
LeftComment, RightComment string
// TrimMarker abuts a delimiter to trim adjacent whitespace.
TrimMarker string
}
GoTemplateGrammar is the lexical vocabulary of Go's text/template, read out of the standard library's own lexer and function table. All three are unexported there, so they are recovered from the AST -- the same approach gencel already uses to read gomplate's own sources.
func ParseGoTemplate ¶
func ParseGoTemplate() (*GoTemplateGrammar, error)
ParseGoTemplate recovers the text/template vocabulary from the standard library sources of the toolchain building this package.