script

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

README

Bitflow Script Antlr implementation

Implementation approach

Overview

The Listener pattern of ANTLR is used, not the Visitor pattern, because the Golang version of the visitor pattern is not functioning yet. See Github

  • internal package: contains the code generated by ANTLR.
  • parser.go: the parser implementation, takes a bitflow script and returns an executable pipeline
  • generic_stack.go: used for agent parser, see below
State and GenericStack

The agent_parser implements the antlr listener of the bitflow script grammar. Instances of GenericStack are used to keep the state while building nested pipelines. If state needs to be stored, it is pushed onto the appropriate stack and popped when not used anymore. This works well, because the listener moves through the AST using a DEPTH FIRST algorithm. Therefore nested Forks, Windows, etc. naturally work until the physical memory is full.

Example with a fork:

   Enter Fork:                      Push empty list to the forkedSubPipelines stack
	    EnterNamedSubPipeline:      Push empty pipeline on the pipeline stack 
		      EnterTransform:       -
		      ExitTransform:        Add transform to the pipeline on top of stack, which is the pushed subpipeline
	    ExitNamedSubPipeline:       pop last subpipeline from stack and add it to the list at the top of the forkedSubPipelines stack
	    EnterNamedSubPipeline:      Push empty subpipeline on the pipeline stack
		      ...create subpipe...  -
	    ExitNamedSubPipeline:       pop last subpipeline from stack and add it to the list at the top of the forkedSubPipelines stack
    Exit Fork:                      create Fork with all subpipelines from the top of forkedSubPipelines

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AntlrBitflowListener

type AntlrBitflowListener struct {
	internal.BaseBitflowListener
	// contains filtered or unexported fields
}

AntlrBitflowListener is a complete listener for a parse tree produced by BitflowParser.

func (*AntlrBitflowListener) EnterFork

func (s *AntlrBitflowListener) EnterFork(ctx *internal.ForkContext)

func (*AntlrBitflowListener) EnterMultiInputPipeline

func (s *AntlrBitflowListener) EnterMultiInputPipeline(ctx *internal.MultiInputPipelineContext)

func (*AntlrBitflowListener) EnterMultiplexFork

func (s *AntlrBitflowListener) EnterMultiplexFork(ctx *internal.MultiplexForkContext)

func (*AntlrBitflowListener) EnterNamedSubPipeline

func (s *AntlrBitflowListener) EnterNamedSubPipeline(ctx *internal.NamedSubPipelineContext)

func (*AntlrBitflowListener) EnterPipeline

func (s *AntlrBitflowListener) EnterPipeline(ctx *internal.PipelineContext)

func (*AntlrBitflowListener) EnterSubPipeline

func (s *AntlrBitflowListener) EnterSubPipeline(ctx *internal.SubPipelineContext)

func (*AntlrBitflowListener) EnterTransformParameters

func (s *AntlrBitflowListener) EnterTransformParameters(ctx *internal.TransformParametersContext)

func (*AntlrBitflowListener) EnterWindow

func (s *AntlrBitflowListener) EnterWindow(ctx *internal.WindowContext)

func (*AntlrBitflowListener) EnterWindowPipeline

func (s *AntlrBitflowListener) EnterWindowPipeline(ctx *internal.WindowPipelineContext)

func (*AntlrBitflowListener) ExitFork

func (s *AntlrBitflowListener) ExitFork(ctx *internal.ForkContext)

func (*AntlrBitflowListener) ExitInput

func (s *AntlrBitflowListener) ExitInput(ctx *internal.InputContext)

func (*AntlrBitflowListener) ExitMultiplexFork

func (s *AntlrBitflowListener) ExitMultiplexFork(ctx *internal.MultiplexForkContext)

func (*AntlrBitflowListener) ExitMultiplexSubPipeline

func (s *AntlrBitflowListener) ExitMultiplexSubPipeline(ctx *internal.MultiplexSubPipelineContext)

func (*AntlrBitflowListener) ExitNamedSubPipeline

func (s *AntlrBitflowListener) ExitNamedSubPipeline(ctx *internal.NamedSubPipelineContext)

func (*AntlrBitflowListener) ExitOutput

func (s *AntlrBitflowListener) ExitOutput(ctx *internal.OutputContext)

func (*AntlrBitflowListener) ExitParameter

func (s *AntlrBitflowListener) ExitParameter(ctx *internal.ParameterContext)

func (*AntlrBitflowListener) ExitTransform

func (s *AntlrBitflowListener) ExitTransform(ctx *internal.TransformContext)

func (*AntlrBitflowListener) ExitWindow

func (s *AntlrBitflowListener) ExitWindow(ctx *internal.WindowContext)

func (*AntlrBitflowListener) SyntaxError

func (s *AntlrBitflowListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException)

type AntlrBitflowScriptScheduleListener

type AntlrBitflowScriptScheduleListener struct {
	internal.BaseBitflowListener
	// contains filtered or unexported fields
}

AntlrBitflowScriptScheduleListener is a complete listener for a parse tree produced by BitflowParser.

func (*AntlrBitflowScriptScheduleListener) EnterSchedulingHints

func (*AntlrBitflowScriptScheduleListener) ExitSchedulingHints

func (*AntlrBitflowScriptScheduleListener) ExitSchedulingParameter

func (*AntlrBitflowScriptScheduleListener) ExitScript

func (*AntlrBitflowScriptScheduleListener) SyntaxError

func (el *AntlrBitflowScriptScheduleListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException)

type BitflowScriptParser

type BitflowScriptParser struct {
	Registry      reg.ProcessorRegistry
	RecoverPanics bool
}

func (*BitflowScriptParser) ParseScript

func (s *BitflowScriptParser) ParseScript(script string) (*bitflow.SamplePipeline, golib.MultiError)

type BitflowScriptScheduleParser

type BitflowScriptScheduleParser struct {
	RecoverPanics bool
}

func (*BitflowScriptScheduleParser) ParseScript

type GenericStack

type GenericStack [][]interface{}

func (*GenericStack) Append

func (s *GenericStack) Append(objs ...interface{})

func (*GenericStack) Clear

func (s *GenericStack) Clear()

func (*GenericStack) Peek

func (s *GenericStack) Peek() []interface{}

func (*GenericStack) PeekSingle

func (s *GenericStack) PeekSingle() interface{}

func (*GenericStack) Pop

func (s *GenericStack) Pop() []interface{}

func (*GenericStack) PopSingle

func (s *GenericStack) PopSingle() interface{}

func (*GenericStack) Push

func (s *GenericStack) Push(objs ...interface{})

type HintedSubscript

type HintedSubscript struct {
	Index  int
	Script string
	Hints  map[string]string
}

type ParserError

type ParserError struct {
	Pos     antlr.ParserRuleContext
	Message string
}

func (ParserError) Error

func (e ParserError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL