generator

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Assignments = make(map[string]Assignment)
View Source
var Events = map[string]func(g *generator, stmt *parser.StmtEvent) (*blocks.Block, error){
	"launch":   eventLaunch,
	"button":   eventButton,
	"joystick": eventDirectionKey,
	"tilt":     eventAction(blocks.EventDetectAttitude, "tilt", "left", "right", "forward", "backward"),
	"face":     eventAction(blocks.EventDetectAttitude, "face", "up", "down"),
	"wave":     eventAction(blocks.EventDetectAction, "wave", "left", "right"),
	"rotate":   eventAction(blocks.EventDetectAction, "", "clockwise", "anticlockwise"),
	"fall":     eventActionSingle(blocks.EventDetectAction, "freefall"),
	"shake":    eventActionSingle(blocks.EventDetectAction, "shake"),
	"light":    eventSensor("light_sensor"),
	"sound":    eventSensor("microphone"),
	"shakeval": eventSensor("shakeval"),
	"timer":    eventSensor("timer"),
	"receive":  eventReceive,
}
View Source
var ExprFuncCalls = map[string]ExprFuncCall{
	"mbot.isButtonPressed":   exprFuncIsButtonPressed,
	"mbot.buttonPressCount":  exprFuncButtonPressCount,
	"mbot.isJoystickPulled":  exprFuncIsJoystickPulled,
	"mbot.joystickPullCount": exprFuncJoystickPullCount,

	"lights.front.brightness": exprFuncLEDAmbientBrightness,

	"sensors.isTilted":   exprFuncIsTilted,
	"sensors.isFaceUp":   exprFuncIsFaceUp,
	"sensors.isWaving":   exprFuncDetectAction([]string{"up", "down", "left", "right"}, "wave"),
	"sensors.isRotating": exprFuncDetectAction([]string{"clockwise", "anticlockwise"}, ""),
	"sensors.isFalling":  exprFuncDetectSingleAction("freefall"),
	"sensors.isShaking":  exprFuncDetectSingleAction("shake"),

	"sensors.tiltAngle":     exprFuncTiltAngle([]string{"forward", "backward", "left", "right"}),
	"sensors.rotationAngle": exprFuncTiltAngle([]string{"clockwise", "anticlockwise"}),

	"sensors.acceleration": exprFuncAcceleration,
	"sensors.rotation":     exprFuncRotation,
	"sensors.angleSpeed":   exprFuncAngleSpeed,

	"sensors.colorStatus":   exprFuncColorStatus,
	"sensors.getColorValue": exprFuncGetColorValue,
	"sensors.getColorName":  exprFuncGetColorName,
	"sensors.isColorStatus": exprFuncIsColorStatus,
	"sensors.detectColor":   exprFuncDetectColor,
	"motors.rpm":            exprFuncMotorsSpeed("speed"),
	"motors.power":          exprFuncMotorsSpeed("power"),
	"motors.angle":          exprFuncMotorsAngle,

	"net.receive": exprFuncNetReceive,

	"math.round":      exprFuncMathRound,
	"math.random":     exprFuncMathRandom,
	"math.abs":        exprFuncMathOp("abs"),
	"math.floor":      exprFuncMathOp("floor"),
	"math.ceil":       exprFuncMathOp("ceil"),
	"math.sqrt":       exprFuncMathOp("sqrt"),
	"math.sin":        exprFuncMathOp("sin"),
	"math.cos":        exprFuncMathOp("cos"),
	"math.tan":        exprFuncMathOp("tan"),
	"math.asin":       exprFuncMathOp("asin"),
	"math.acos":       exprFuncMathOp("acos"),
	"math.atan":       exprFuncMathOp("atan"),
	"math.ln":         exprFuncMathOp("ln"),
	"math.log":        exprFuncMathOp("log"),
	"math.ePowerOf":   exprFuncMathOp("e ^"),
	"math.tenPowerOf": exprFuncMathOp("10 ^"),

	"strings.length":   exprFuncStringsLength,
	"strings.letter":   exprFuncStringsLetter,
	"strings.contains": exprFuncStringsContains,

	"lists.get":      exprFuncListsGet,
	"lists.indexOf":  exprFuncListsIndexOf,
	"lists.length":   exprFuncListsLength,
	"lists.contains": exprFuncListsContains,

	"display.pixelIsColor": exprFuncDisplayPixelIsColor,
	"sprite.touchesSprite": exprFuncSpriteTouchesSprite,
	"sprite.touchesEdge":   exprFuncSpriteTouchesEdge,
	"sprite.positionX":     exprFuncSpritePosition("get_x"),
	"sprite.positionY":     exprFuncSpritePosition("get_y"),
	"sprite.rotation":      exprFuncSpritePosition("get_rotation"),
	"sprite.scale":         exprFuncSpritePosition("get_size"),
	"sprite.anchor":        exprFuncSpritePosition("get_align"),

	"convert.toString": exprFuncConvert("str"),
	"convert.toNumber": exprFuncConvert("float"),
}
View Source
var FuncCalls = map[string]FuncCall{}/* 113 elements not displayed */
View Source
var Variables = make(map[string]Var)

Functions

func GenerateBlocks

func GenerateBlocks(statements []parser.Stmt, definitions analyzer.Definitions) (map[string]*blocks.Block, []error)

func Package

func Package(writer io.Writer, blocks []map[string]*blocks.Block, definitions []analyzer.Definitions) error

Types

type Assignment

type Assignment struct {
	Name         string
	AssignType   blocks.BlockType
	IncreaseType blocks.BlockType
	InputName    string
}

type ExprFuncCall

type ExprFuncCall func(g *generator, expr *parser.ExprFuncCall) (*blocks.Block, error)

type FuncCall

type FuncCall func(g *generator, stmt *parser.StmtCall) (*blocks.Block, error)

type GenerateError

type GenerateError struct {
	Start   parser.Position
	End     parser.Position
	Message string
	Warning bool
}

func (GenerateError) Error

func (e GenerateError) Error() string

type Var

type Var struct {
	Name string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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