Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// ModulePath is the path to the module. REQUIRED!
ModulePath string
// MuduleName is the name of the module. Uses the meta.language field by default.
ModuleName string
// GrammarLocations are aliases to the grammar locations.
// e.g. 'spec.pegn.dev': 'https://raw.githubusercontent.com/pegn/spec/master/grammar.pegn'
GrammarLocations map[string]string
// IgnoreReserved makes sure the generator does not return a error when it
// tries to generate a reserved class/token. False by default, you should
// not overwrite reserved classes or tokens.
IgnoreReserved bool
// TokenPrefix represents the prefix before a token name. No prefix is added
// when the value is an empty string.
// e.g. 'SP' with prefix 'Token' results in 'TokenSP'.
TokenPrefix string
// TokenSubPackage is the name of the sub-package for tokens. It left empty
// the tokens will get added to the main file.
TokenSubPackage string
// TypeSuffix represent the pre- or suffix before a class name.
// Recommended. Type names are the same as there corresponding parse
// functions. e.g. 'Grammar' with suffix 'Type' results in 'GrammarType'.
TypeSuffix string
// TypeSubPackage is the name of the sub-package for types. It left empty
// the types will get added to the main file.
TypeSubPackage string
// ClassAliases is a map of original class names to an alias.
// e.g. map[alphanum: AlphaNum]
ClassAliases map[string]string
// ClassSubPackage is the name of the sub-package for classes. It left empty
// the classes will get added to the main file.
ClassSubPackage string
// NodeAliases is a map of original node names to an alias.
// e.g. map[Hexadec: Hexadecimal]
NodeAliases map[string]string
}
Config that offers additional configuration options to the generator.
type InMemoryParser ¶
type InMemoryParser struct {
// contains filtered or unexported fields
}
InMemoryParser is the in-memory equivalent of generated code of generator.
func ParserFromFiles ¶
func ParserFromFiles(config Config, grammar []byte, dependencies ...[]byte) (InMemoryParser, error)
ParserFromFiles creates an in-memory parser based on the given configuration and files.
func ParserFromURLs ¶
func ParserFromURLs(config Config, urls ...string) (InMemoryParser, error)
ParserFromURLs creates an in-memory parser based on the given configuration and urls.
func (*InMemoryParser) GetClassDef ¶
func (i *InMemoryParser) GetClassDef(id string) (interface{}, error)
GetClassDef returns a class definition.
func (*InMemoryParser) GetNodeDef ¶
func (i *InMemoryParser) GetNodeDef(id string) (interface{}, error)
GetNodeDef returns a node definition.
func (*InMemoryParser) GetTokenDef ¶
func (i *InMemoryParser) GetTokenDef(id string) (interface{}, error)
GetTokenDef returns a token definition.
type ReservedIdentifierError ¶
type ReservedIdentifierError struct {
// contains filtered or unexported fields
}
ReservedIdentifierError indicates that the grammar overwrites one of the predefined/reserved (default) PEGN classes or tokens.
func (*ReservedIdentifierError) Error ¶
func (r *ReservedIdentifierError) Error() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.