compiler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(file string) (retUnit []*definition.CompilationUnit, retErr error, retWarning error)

Types

type CompilationRuntime

type CompilationRuntime struct {
	Units      *util.OrderedMap[string, *definition.CompilationUnit] // Units contains all the units compiled, full path as key
	Packages   *util.OrderedMap[string, *definition.CompilationUnit] // another view of Units, for faster package lookup, package name as key
	ParseStack *util.OrderedMap[string, *definition.CompilationUnit] // ParseStack contains all the units being parsed, full path as key
}

func NewCompilationRuntime

func NewCompilationRuntime() *CompilationRuntime

func (*CompilationRuntime) Compile

func (r *CompilationRuntime) Compile(file *definition.FileIdentifer) (retUnit *definition.CompilationUnit, retErr error, retWarning error)

func (*CompilationRuntime) CompileFile

func (r *CompilationRuntime) CompileFile(file string) (retUnit *definition.CompilationUnit, retErr error, retWarning error)

type ExprVisitor

type ExprVisitor struct {
	*MethodVisitor
	ValueType *definition.BasicType
}

func NewExprVisitor

func NewExprVisitor(v *MethodVisitor, valueType *definition.BasicType) *ExprVisitor

func (*ExprVisitor) VisitExprAddSub

func (v *ExprVisitor) VisitExprAddSub(ctx *parser.ExprAddSubContext) any

func (*ExprVisitor) VisitExprBitAnd

func (v *ExprVisitor) VisitExprBitAnd(ctx *parser.ExprBitAndContext) any

func (*ExprVisitor) VisitExprBitOr

func (v *ExprVisitor) VisitExprBitOr(ctx *parser.ExprBitOrContext) any

func (*ExprVisitor) VisitExprBitXor

func (v *ExprVisitor) VisitExprBitXor(ctx *parser.ExprBitXorContext) any

func (*ExprVisitor) VisitExprCast

func (v *ExprVisitor) VisitExprCast(ctx *parser.ExprCastContext) any

func (*ExprVisitor) VisitExprConstant

func (v *ExprVisitor) VisitExprConstant(ctx *parser.ExprConstantContext) any

func (*ExprVisitor) VisitExprEquality

func (v *ExprVisitor) VisitExprEquality(ctx *parser.ExprEqualityContext) any

func (*ExprVisitor) VisitExprLogicalAnd

func (v *ExprVisitor) VisitExprLogicalAnd(ctx *parser.ExprLogicalAndContext) any

func (*ExprVisitor) VisitExprLogicalOr

func (v *ExprVisitor) VisitExprLogicalOr(ctx *parser.ExprLogicalOrContext) any

func (*ExprVisitor) VisitExprMulDivMod

func (v *ExprVisitor) VisitExprMulDivMod(ctx *parser.ExprMulDivModContext) any

func (*ExprVisitor) VisitExprParens

func (v *ExprVisitor) VisitExprParens(ctx *parser.ExprParensContext) any

func (*ExprVisitor) VisitExprPower

func (v *ExprVisitor) VisitExprPower(ctx *parser.ExprPowerContext) any

func (*ExprVisitor) VisitExprRelational

func (v *ExprVisitor) VisitExprRelational(ctx *parser.ExprRelationalContext) any

func (*ExprVisitor) VisitExprShift

func (v *ExprVisitor) VisitExprShift(ctx *parser.ExprShiftContext) any

func (*ExprVisitor) VisitExprTernary

func (v *ExprVisitor) VisitExprTernary(ctx *parser.ExprTernaryContext) any

func (*ExprVisitor) VisitExprUnary

func (v *ExprVisitor) VisitExprUnary(ctx *parser.ExprUnaryContext) any

func (*ExprVisitor) VisitExprValue

func (v *ExprVisitor) VisitExprValue(ctx *parser.ExprValueContext) any

type ImportVisitor

type ImportVisitor struct {
	parser.BasebubblerVisitor
	File    *definition.FileIdentifer
	Imports []*definition.FileIdentifer
	PosList []*definition.BasePosition
}

func NewImportVisitor

func NewImportVisitor(File *definition.FileIdentifer) *ImportVisitor

func (*ImportVisitor) VisitImportStatement

func (v *ImportVisitor) VisitImportStatement(ctx *parser.ImportStatementContext) any

func (*ImportVisitor) VisitProto

func (v *ImportVisitor) VisitProto(ctx *parser.ProtoContext) any

type InfoVisitor

func NewInfoVisitor

func NewInfoVisitor(unit *definition.CompilationUnit) *InfoVisitor

func (*InfoVisitor) VisitFullIdent

func (v *InfoVisitor) VisitFullIdent(ctx *parser.FullIdentContext) any

func (*InfoVisitor) VisitOptionStatement

func (v *InfoVisitor) VisitOptionStatement(ctx *parser.OptionStatementContext) any

func (*InfoVisitor) VisitPackageStatement

func (v *InfoVisitor) VisitPackageStatement(ctx *parser.PackageStatementContext) any

func (*InfoVisitor) VisitProto

func (v *InfoVisitor) VisitProto(ctx *parser.ProtoContext) any

type LiteralVisitor

type LiteralVisitor struct {
	parser.BasebubblerVisitor
	Unit *definition.CompilationUnit
}

func NewLiteralVisitor

func NewLiteralVisitor(unit *definition.CompilationUnit) *LiteralVisitor

func (*LiteralVisitor) VisitBoolLit

func (v *LiteralVisitor) VisitBoolLit(ctx *parser.BoolLitContext) any

VisitBoolLit noexcept returns bool

func (*LiteralVisitor) VisitConstant

func (v *LiteralVisitor) VisitConstant(ctx *parser.ConstantContext) any

VisitConstant returns Literal or error

func (*LiteralVisitor) VisitFloatLit

func (v *LiteralVisitor) VisitFloatLit(ctx *parser.FloatLitContext) any

VisitFloatLit returns float64 or error

func (*LiteralVisitor) VisitIdent

func (v *LiteralVisitor) VisitIdent(ctx *parser.IdentContext) any

VisitIdent noexcept returns string

func (*LiteralVisitor) VisitIntLit

func (v *LiteralVisitor) VisitIntLit(ctx *parser.IntLitContext) any

VisitIntLit returns int64 or error

func (*LiteralVisitor) VisitStrLit

func (v *LiteralVisitor) VisitStrLit(ctx *parser.StrLitContext) any

VisitStrLit returns string or error

func (*LiteralVisitor) VisitValue

func (v *LiteralVisitor) VisitValue(ctx *parser.ValueContext) any

VisitValue returns ValueExpr

type MethodVisitor

type MethodVisitor struct {
	*ProtoVisitor
	FieldType *definition.BasicType
}

func NewMethodVisitor

func NewMethodVisitor(v *ProtoVisitor, fieldType *definition.BasicType) *MethodVisitor

func (*MethodVisitor) VisitFieldMethod

func (v *MethodVisitor) VisitFieldMethod(ctx *parser.FieldMethodContext) any

func (*MethodVisitor) VisitFieldMethods

func (v *MethodVisitor) VisitFieldMethods(ctx *parser.FieldMethodsContext) any

func (*MethodVisitor) VisitMethodName

func (v *MethodVisitor) VisitMethodName(ctx *parser.MethodNameContext) any

type OptionValidator

type OptionValidator struct {
	OptionType   *util.OrderedMap[string, definition.LiteralKindID]
	OptionValues *util.OrderedMap[string, *util.OrderedMap[any, any]]
}
var EnumValueOptionValidator *OptionValidator
var FieldOptionValidator *OptionValidator
var FileOptionValidator *OptionValidator

func NewOptionValidator

func NewOptionValidator() *OptionValidator

func (*OptionValidator) AddOption

func (v *OptionValidator) AddOption(name string, ty definition.LiteralKindID, values ...any)

func (*OptionValidator) ValidateOption

func (v *OptionValidator) ValidateOption(option *definition.Option) error

type PrintVisitor

type PrintVisitor struct {
	parser.BasebubblerVisitor
}

func NewPrintVisitor

func NewPrintVisitor() *PrintVisitor

type ProtoVisitor

type ProtoVisitor struct {
	parser.BasebubblerVisitor
	Unit    *definition.CompilationUnit
	Warning definition.TopLevelWarning
}

func NewParseVisitor

func NewParseVisitor(unit *definition.CompilationUnit) *ProtoVisitor

func (*ProtoVisitor) VisitArrayElementType

func (v *ProtoVisitor) VisitArrayElementType(ctx *parser.ArrayElementTypeContext) any

func (*ProtoVisitor) VisitArrayType

func (v *ProtoVisitor) VisitArrayType(ctx *parser.ArrayTypeContext) any

func (*ProtoVisitor) VisitBasicType

func (v *ProtoVisitor) VisitBasicType(ctx *parser.BasicTypeContext) any

func (*ProtoVisitor) VisitBitSize

func (v *ProtoVisitor) VisitBitSize(ctx *parser.BitSizeContext) any

func (*ProtoVisitor) VisitBoolLit

func (v *ProtoVisitor) VisitBoolLit(ctx *parser.BoolLitContext) any

VisitBoolLit noexcept returns bool

func (*ProtoVisitor) VisitByteSize

func (v *ProtoVisitor) VisitByteSize(ctx *parser.ByteSizeContext) any

func (*ProtoVisitor) VisitConstant

func (v *ProtoVisitor) VisitConstant(ctx *parser.ConstantContext) any

VisitConstant returns Literal or error

func (*ProtoVisitor) VisitEmptyStatement_

func (v *ProtoVisitor) VisitEmptyStatement_(ctx *parser.EmptyStatement_Context) any

func (*ProtoVisitor) VisitEnumBody

func (v *ProtoVisitor) VisitEnumBody(ctx *parser.EnumBodyContext) any

func (*ProtoVisitor) VisitEnumDef

func (v *ProtoVisitor) VisitEnumDef(ctx *parser.EnumDefContext) any

func (*ProtoVisitor) VisitEnumElement

func (v *ProtoVisitor) VisitEnumElement(ctx *parser.EnumElementContext) any

func (*ProtoVisitor) VisitEnumName

func (v *ProtoVisitor) VisitEnumName(ctx *parser.EnumNameContext) any

func (*ProtoVisitor) VisitEnumType

func (v *ProtoVisitor) VisitEnumType(ctx *parser.EnumTypeContext) any

func (*ProtoVisitor) VisitEnumValue

func (v *ProtoVisitor) VisitEnumValue(ctx *parser.EnumValueContext) any

func (*ProtoVisitor) VisitEnumValueName

func (v *ProtoVisitor) VisitEnumValueName(ctx *parser.EnumValueNameContext) any

func (*ProtoVisitor) VisitEnumValueOption

func (v *ProtoVisitor) VisitEnumValueOption(ctx *parser.EnumValueOptionContext) any

TODO: parse enum options

func (*ProtoVisitor) VisitEnumValueOptions

func (v *ProtoVisitor) VisitEnumValueOptions(ctx *parser.EnumValueOptionsContext) any

TODO: parse enum options

func (ProtoVisitor) VisitExprAddSub

func (ProtoVisitor) VisitExprAddSub(ctx *parser.ExprAddSubContext) any

func (ProtoVisitor) VisitExprBitAnd

func (ProtoVisitor) VisitExprBitAnd(ctx *parser.ExprBitAndContext) any

func (ProtoVisitor) VisitExprBitOr

func (ProtoVisitor) VisitExprBitOr(ctx *parser.ExprBitOrContext) any

func (ProtoVisitor) VisitExprBitXor

func (ProtoVisitor) VisitExprBitXor(ctx *parser.ExprBitXorContext) any

func (ProtoVisitor) VisitExprCast

func (ProtoVisitor) VisitExprCast(ctx *parser.ExprCastContext) any

func (ProtoVisitor) VisitExprConstant

func (ProtoVisitor) VisitExprConstant(ctx *parser.ExprConstantContext) any

func (ProtoVisitor) VisitExprEquality

func (ProtoVisitor) VisitExprEquality(ctx *parser.ExprEqualityContext) any

func (ProtoVisitor) VisitExprLogicalAnd

func (ProtoVisitor) VisitExprLogicalAnd(ctx *parser.ExprLogicalAndContext) any

func (ProtoVisitor) VisitExprLogicalOr

func (ProtoVisitor) VisitExprLogicalOr(ctx *parser.ExprLogicalOrContext) any

func (ProtoVisitor) VisitExprMulDivMod

func (ProtoVisitor) VisitExprMulDivMod(ctx *parser.ExprMulDivModContext) any

func (ProtoVisitor) VisitExprParens

func (ProtoVisitor) VisitExprParens(ctx *parser.ExprParensContext) any

func (ProtoVisitor) VisitExprPower

func (ProtoVisitor) VisitExprPower(ctx *parser.ExprPowerContext) any

func (ProtoVisitor) VisitExprRelational

func (ProtoVisitor) VisitExprRelational(ctx *parser.ExprRelationalContext) any

func (ProtoVisitor) VisitExprShift

func (ProtoVisitor) VisitExprShift(ctx *parser.ExprShiftContext) any

func (ProtoVisitor) VisitExprTernary

func (ProtoVisitor) VisitExprTernary(ctx *parser.ExprTernaryContext) any

func (ProtoVisitor) VisitExprUnary

func (ProtoVisitor) VisitExprUnary(ctx *parser.ExprUnaryContext) any

func (ProtoVisitor) VisitExprValue

func (ProtoVisitor) VisitExprValue(ctx *parser.ExprValueContext) any

func (*ProtoVisitor) VisitField

func (v *ProtoVisitor) VisitField(ctx *parser.FieldContext) any

func (*ProtoVisitor) VisitFieldConstant

func (v *ProtoVisitor) VisitFieldConstant(ctx *parser.FieldConstantContext) any

func (*ProtoVisitor) VisitFieldEmbedded

func (v *ProtoVisitor) VisitFieldEmbedded(ctx *parser.FieldEmbeddedContext) any

func (ProtoVisitor) VisitFieldMethod

func (ProtoVisitor) VisitFieldMethod(ctx *parser.FieldMethodContext) any

func (ProtoVisitor) VisitFieldMethods

func (ProtoVisitor) VisitFieldMethods(ctx *parser.FieldMethodsContext) any

func (*ProtoVisitor) VisitFieldName

func (v *ProtoVisitor) VisitFieldName(ctx *parser.FieldNameContext) any

func (*ProtoVisitor) VisitFieldNormal

func (v *ProtoVisitor) VisitFieldNormal(ctx *parser.FieldNormalContext) any

func (*ProtoVisitor) VisitFieldOption

func (v *ProtoVisitor) VisitFieldOption(ctx *parser.FieldOptionContext) any

func (*ProtoVisitor) VisitFieldOptions

func (v *ProtoVisitor) VisitFieldOptions(ctx *parser.FieldOptionsContext) any

func (*ProtoVisitor) VisitFieldVoid

func (v *ProtoVisitor) VisitFieldVoid(ctx *parser.FieldVoidContext) any

func (*ProtoVisitor) VisitFloatLit

func (v *ProtoVisitor) VisitFloatLit(ctx *parser.FloatLitContext) any

VisitFloatLit returns float64 or error

func (ProtoVisitor) VisitFullIdent

func (ProtoVisitor) VisitFullIdent(ctx *parser.FullIdentContext) any

func (*ProtoVisitor) VisitIdent

func (v *ProtoVisitor) VisitIdent(ctx *parser.IdentContext) any

VisitIdent noexcept returns string

func (*ProtoVisitor) VisitImportStatement

func (v *ProtoVisitor) VisitImportStatement(ctx *parser.ImportStatementContext) any

func (*ProtoVisitor) VisitIntLit

func (v *ProtoVisitor) VisitIntLit(ctx *parser.IntLitContext) any

VisitIntLit returns int64 or error

func (ProtoVisitor) VisitMethodName

func (ProtoVisitor) VisitMethodName(ctx *parser.MethodNameContext) any

func (*ProtoVisitor) VisitOptionName

func (v *ProtoVisitor) VisitOptionName(ctx *parser.OptionNameContext) any

func (ProtoVisitor) VisitOptionStatement

func (ProtoVisitor) VisitOptionStatement(ctx *parser.OptionStatementContext) any

func (ProtoVisitor) VisitPackageStatement

func (ProtoVisitor) VisitPackageStatement(ctx *parser.PackageStatementContext) any

func (*ProtoVisitor) VisitProto

func (v *ProtoVisitor) VisitProto(ctx *parser.ProtoContext) any

VisitProto returns nil

func (*ProtoVisitor) VisitSize_

func (v *ProtoVisitor) VisitSize_(ctx *parser.Size_Context) any

func (*ProtoVisitor) VisitStrLit

func (v *ProtoVisitor) VisitStrLit(ctx *parser.StrLitContext) any

VisitStrLit returns string or error

func (*ProtoVisitor) VisitStructBody

func (v *ProtoVisitor) VisitStructBody(ctx *parser.StructBodyContext) any

func (*ProtoVisitor) VisitStructDef

func (v *ProtoVisitor) VisitStructDef(ctx *parser.StructDefContext) any

VisitStructDef returns Struct or error

func (*ProtoVisitor) VisitStructElement

func (v *ProtoVisitor) VisitStructElement(ctx *parser.StructElementContext) any

func (*ProtoVisitor) VisitStructName

func (v *ProtoVisitor) VisitStructName(ctx *parser.StructNameContext) any

func (*ProtoVisitor) VisitStructType

func (v *ProtoVisitor) VisitStructType(ctx *parser.StructTypeContext) any

func (*ProtoVisitor) VisitTopLevelDef

func (v *ProtoVisitor) VisitTopLevelDef(ctx *parser.TopLevelDefContext) any

VisitTopLevelDef returns CustomType or error

func (*ProtoVisitor) VisitType_

func (v *ProtoVisitor) VisitType_(ctx *parser.Type_Context) any

func (*ProtoVisitor) VisitValue

func (v *ProtoVisitor) VisitValue(ctx *parser.ValueContext) any

VisitValue noexcept returns *definition.ValueExpr

Jump to

Keyboard shortcuts

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