Documentation ¶
Index ¶
Constants ¶
const ( ErrAutoScopes = "automatic scope limiters have not been implemented yet" ErrEmptyGen = "Nothing specified after ::gen" // Thinking of calling this thing "Anycode Preprocessor", // but for now it's "genner". TmpFilePrefix = "genner_" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Genner ¶
type Genner struct { Do TaskGenerator Interp interp_a.HybridEvaluator }
Genner is a wrapper for the task generator which also provides access to the interpreter.
func NewDefaultGenner ¶
func NewDefaultGenner() Genner
func NewGennerHackyRegexCat ¶
func NewGennerHackyRegexCat(ii interp_a.HybridEvaluator, prefix string) Genner
func NewGennerWithBuiltinsTest ¶
func NewGennerWithBuiltinsTest() Genner
type GennerEnvironment ¶
type GennerEnvironment interface {
SetInputBuffer([]string)
}
type GennerEnvironmentDefault ¶
type GennerEnvironmentDefault struct {
// contains filtered or unexported fields
}
func (*GennerEnvironmentDefault) OpReadInput ¶
func (env *GennerEnvironmentDefault) OpReadInput([]interface{}) ([]interface{}, error)
func (*GennerEnvironmentDefault) SetInputBuffer ¶
func (env *GennerEnvironmentDefault) SetInputBuffer(buffer []string)
type IndentationSet ¶
type IndentationSet struct {
// contains filtered or unexported fields
}
func NewIndentationSet ¶
func NewIndentationSet(runes []rune) IndentationSet
func (IndentationSet) TrimAndKeep ¶
func (indents IndentationSet) TrimAndKeep(subject string) ( modified, indent string, )
TrimAndKeep trims left space as defined by the indentation set, and reports both the trimmed string and a string holding the indentation characters.
type TaskGenerator ¶
type TaskGenerator struct { // Line types IsRunLine *regexp.Regexp // "//::declare" IsGenLine *regexp.Regexp // "//::gen" IsEndLine *regexp.Regexp // "//::end" // Indentation characters Indents IndentationSet // Main parsing operation Exec interp_a.Operation // API to environment Env GennerEnvironment }
func (TaskGenerator) GenerateUpdateFile ¶
func (genner TaskGenerator) GenerateUpdateFile( sourcefile string, ) error
func (TaskGenerator) ProcessLinesAndInsertGeneratedCode ¶
func (genner TaskGenerator) ProcessLinesAndInsertGeneratedCode( lines []string) ([]string, error)
ProcessLinesAndInsertGeneratedCode searches for comments which indicate some code generation operation to perform (which begin with //::gen under the default configuration), runs the operation Exec to produce lines of generated code, and inserts the generated code into a new list. Using the output []string in place of the input []string will effectively replace all ::gen-::end sections with newly generated code.
If an error is reported, lines copied/generated before the error occurred will be returned. This is done to provide helpful debugging information.