Documentation ¶
Index ¶
- Constants
- Variables
- func CrashIfErrorsFound()
- func Error(area string, _type ErrorType, span TextSpan, message string, ...)
- func ErrorS(area string, _type ErrorType, span TextSpan, message string, a ...interface{}) string
- func Format(message string, defaultColour string, a ...interface{}) string
- func GetOffset(nr int) int
- func LookUp(code ErrorCode)
- func PrintC(color string, message string)
- func PrintCF(color string, message string, slotins ...interface{})
- func PrintCodeSnippet(span TextSpan)
- func PrintCodeSnippetS(span TextSpan) string
- func PrintLineOfCode(nr int, line string) int
- func Warning(area string, _type ErrorType, span TextSpan, message string, ...)
- func WriteC(color string, message string)
- func WriteCF(color string, message string, slotins ...interface{})
- type ErrorCode
- type ErrorReport
- type ErrorType
- type TextSpan
Constants ¶
const ( // Developer Error NotImplementedError ErrorType = "NotImplemented" IDK = "IDK(cringe)" // Depreciated (because it's kind of dumb) // Preprocessor Errors FileAlreadyInSourcesWarning = "FileAlreadyInSources Warning" // Lexer Errors UnexpectedCharacterError = "UnexpectedCharacter" FileDoesNotExistError = "FileDoesNotExist" FilePermissionError = "FilePermission" FileVoidError = "FileVoid" RealValueConversionError = "RealValueConversion" // Parser Errors UnexpectedTokenError = "UnexpectedToken" // Binder Errors DuplicateParameterError = "DuplicateParameter" DuplicateFunctionError = "DuplicateFunction" DuplicateVariableDeclarationError = "DuplicateVariableDeclaration" DuplicatePackageImportError = "DuplicatePackageImportError" UndefinedVariableReferenceError = "UndefinedVariableReference" TypeFunctionDoesNotExistError = "TypeFunctionDoesNotExist" ConversionError = "Conversion" ExplicitConversionError = "ExplicitConversion" UnexpectedExpressionStatementError = "UnexpectedExpressionStatement" OutsideReturnError = "OutsideReturn" VoidReturnError = "VoidReturn" OutsideBreakError = "OutsideBreak" UnexpectedNonIntegerValueError = "UnexpectedNonIntegerValue" OutsideContinueError = "OutsideContinue" BinaryOperatorTypeError = "BinaryOperatorType" IncorrectTypeFunctionCallError = "IncorrectTypeFunctionCall" BadNumberOfParametersError = "BadNumberOfParameters" UndefinedFunctionCallError = "UndefinedFunctionCall" UnaryOperatorTypeError = "UnaryOperatorType" UnknownDataTypeError = "UnknownDataType" UnknownStatementError = "UnknownStatement" IllegalVariableDeclarationError = "IllegalVariableDeclarationError" IllegalFunctionSignatureError = "IllegalFunctionSignatureError" IllegalNestedClassesError = "IllegalNestedClassesError" InvalidStatementPlacementError = "InvalidStatementPlacementError" OutsideConstructorCallError = "OutsideConstructorCallError" InvalidClassAccessError = "InvalidClassAccessError" IllegalConstructorCallError = "IllegalConstructorCallError" TernaryOperatorTypeError = "TernaryOperatorTypeError" UnknownClassError = "UnknownClassError" UnknownStructError = "UnknownStructError" FunctionAccessViolationError = "FunctionAccessViolationError" UnknownFieldError = "UnknownFieldError" InvalidNumberOfSubtypesError = "InvalidNumberOfSubtypesError" UnknownPackageError = "UnknownPackageError" UnexpectedNonArrayValueError = "UnexpectedNonArrayValueError" InvalidExternalFunctionPlacementError = "InvalidExternalFunctionPlacementError" UnexpectedNonPointerValueError = "UnexpectedNonPointerValueError" TooManyStructParametersError = "TooManyStructParametersError" OutsideThisError = "OutsideThisError" // Emitter Errors UnknownVTableError = "UnknownVTableError" UnknownConstructorError = "UnknownConsructorError" CAdapterCompilationError = "CAdapterCompilationError" ExternalCAdapterWarning = "ExternalCAdapterWarning" // Packager Errors UnknownPackageModuleFileError = "UnknownPackageModuleFileError" IllegalBoxedTypeError = "IllegalBoxedTypeError" IllegalUnspecificArrayTypeError = "IllegalUnspecificArrayTypeError" MonkeError = "MonkeError" InvalidNonPointerReferenceError = "InvalidNonPointerReferenceError" UnparsableFingerprintError = "UnparsableFingerprintError" ImpossibleFunctionProcessingError = "ImpossibleFunctionProcessingError" ImpossibleFieldProcessingError = "ImpossibleFieldProcessingError" )
const ( // Developer ErrorCodes (start at 9000) (Why? Fuck logic that's why). NotImplementedErrorCode ErrorCode = iota + 9000 IDKErrorCode = iota + 9000 // Depreciated NULLErrorCode = -1 + 9000 // Preprocessor ErrorCodes FileAlreadyInSourcesWarningCode = iota // Lexer ErrorCodes (start at 1000) UnexpectedCharacterErrorCode = iota + 1000 // 1003 FileDoesNotExistErrorCode = iota + 1000 // 1004 FilePermissionErrorCode = iota + 1000 // 1005 FileVoidErrorCode = iota + 1000 // 1006 RealValueConversionErrorCode = iota + 1000 // 1007 // Parser ErrorCodes (start at 2000) UnexpectedTokenErrorCode = iota + 2000 // Binder ErrorCodes (start at 3000) (Chonk warning) DuplicateParameterErrorCode = iota + 3000 // 3009 DuplicateFunctionErrorCode = iota + 3000 DuplicateVariableDeclarationErrorCode = iota + 3000 DuplicatePackageImportErrorCode = iota + 3000 UndefinedVariableReferenceErrorCode = iota + 3000 TypeFunctionDoesNotExistErrorCode = iota + 3000 ConversionErrorCode = iota + 3000 ExplicitConversionErrorCode = iota + 3000 UnexpectedExpressionStatementErrorCode = iota + 3000 OutsideReturnErrorCode = iota + 3000 VoidReturnErrorCode = iota + 3000 OutsideBreakErrorCode = iota + 3000 UnexpectedNonIntegerValueErrorCode = iota + 3000 OutsideContinueErrorCode = iota + 3000 BinaryOperatorTypeErrorCode = iota + 3000 IncorrectTypeFunctionCallErrorCode = iota + 3000 BadNumberOfParametersErrorCode = iota + 3000 UndefinedFunctionCallErrorCode = iota + 3000 UnaryOperatorTypeErrorCode = iota + 3000 UnknownDataTypeErrorCode = iota + 3000 // NOTE: this error does not exist, and I have no idea why! UnknownStatementErrorCode = iota + 3000 IllegalVariableDeclarationErrorCode = iota + 3000 IllegalFunctionSignatureErrorCode = iota + 3000 IllegalNestedClassesErrorCode = iota + 3000 InvalidStatementPlacementErrorCode = iota + 3000 OutsideConstructorCallErrorCode = iota + 3000 InvalidClassAccessErrorCode = iota + 3000 IllegalConstructorCallErrorCode = iota + 3000 TernaryOperatorTypeErrorCode = iota + 3000 UnknownClassErrorCode = iota + 3000 FunctionAccessViolationErrorCode = iota + 3000 UnknownFieldErrorCode = iota + 3000 InvalidNumberOfSubtypesErrorCode = iota + 3000 UnknownPackageErrorCode = iota + 3000 UnexpectedNonArrayValueErrorCode = iota + 3000 InvalidExternalFunctionPlacementErrorCode = iota + 3000 UnexpectedNonPointerValueErrorCode = iota + 3000 UnknownStructErrorCode = iota + 3000 TooManyStructParametersErrorCode = iota + 3000 OutsideThisErrorCode = iota + 3000 // Emitter ErrorCodes UnknownVTableErrorCode = iota + 4000 UnknownConstructorErrorCode = iota + 4000 CAdapterCompilationErrorCode = iota + 4000 ExternalCAdapterWarningCode = iota + 4000 // Packager ErrorCodes UnknownPackageModuleFileErrorCode = iota + 5000 IllegalBoxedTypeErrorCode = iota + 5000 IllegalUnspecificArrayTypeErrorCode = iota + 5000 MonkeErrorCode = iota + 5000 InvalidNonPointerReferenceErrorCode = iota + 5000 UnparsableFingerprintErrorCode = iota + 5000 ImpossibleFunctionProcessingErrorCode = iota + 5000 ImpossibleFieldProcessingErrorCode = iota + 5000 )
const ( Black = "\033[1;30m%s\033[0m" // &bl DarkRed = "\033[1;31m%s\033[0m" // &dr DarkGreen = "\033[1;32m%s\033[0m" // &dg DarkYellow = "\033[1;33m%s\033[0m" // &dy DarkBlue = "\033[1;34m%s\033[0m" // &db Magenta = "\033[1;35m%s\033[0m" // &m DarkCyan = "\033[1;36m%s\033[0m" // &dc Gray = "\033[1;37m%s\033[0m" // &gr DarkGray = "\033[1;90m%s\033[0m" // &dgr Red = "\033[1;91m%s\033[0m" // &r Green = "\033[1;92m%s\033[0m" // &g Yellow = "\033[1;93m%s\033[0m" // &y Blue = "\033[1;94m%s\033[0m" // &b Pink = "\033[1;95m%s\033[0m" // &p Cyan = "\033[1;96m%s\033[0m" // &c White = "\033[1;97m%s\033[0m" // &w EBlack = "\033[1;30m" EDarkRed = "\033[1;31m" EDarkGreen = "\033[1;32m" EDarkYellow = "\033[1;33m" EDarkBlue = "\033[1;34m" EMagenta = "\033[1;35m" EDarkCyan = "\033[1;36m" EGray = "\033[1;37m" EDarkGray = "\033[1;90m" ERed = "\033[1;91m" EGreen = "\033[1;92m" EYellow = "\033[1;93m" EBlue = "\033[1;94m" EPink = "\033[1;95m" ECyan = "\033[1;96m" EWhite = "\033[1;97m" EReset = "\033[0m" )
Variables ¶
var CodeReference []string = []string{
"&dyvar &wjerr&r@&wy &w<- &g\"Hello, World\"&g;",
}
CodeReference stores code for both error lookups and compiler-time error messages. It stores code for error lookups, when compiling it is overwritten with the code to compile.
var ErrorList = make([]ErrorReport, 0)
var ErrorTypeCodeRelations = map[ErrorType]ErrorCode{ UnexpectedCharacterError: UnexpectedCharacterErrorCode, NotImplementedError: NotImplementedErrorCode, FileDoesNotExistError: FileDoesNotExistErrorCode, FilePermissionError: FilePermissionErrorCode, FileVoidError: FileVoidErrorCode, RealValueConversionError: RealValueConversionErrorCode, UnexpectedTokenError: UnexpectedTokenErrorCode, DuplicateParameterError: DuplicateParameterErrorCode, DuplicateFunctionError: DuplicateFunctionErrorCode, DuplicateVariableDeclarationError: DuplicateVariableDeclarationErrorCode, UndefinedVariableReferenceError: UndefinedVariableReferenceErrorCode, TypeFunctionDoesNotExistError: TypeFunctionDoesNotExistErrorCode, ConversionError: ConversionErrorCode, ExplicitConversionError: ExplicitConversionErrorCode, UnexpectedExpressionStatementError: UnexpectedExpressionStatementErrorCode, OutsideReturnError: OutsideReturnErrorCode, VoidReturnError: VoidReturnErrorCode, OutsideBreakError: OutsideBreakErrorCode, UnexpectedNonIntegerValueError: UnexpectedNonIntegerValueErrorCode, OutsideContinueError: OutsideContinueErrorCode, BinaryOperatorTypeError: BinaryOperatorTypeErrorCode, IncorrectTypeFunctionCallError: IncorrectTypeFunctionCallErrorCode, BadNumberOfParametersError: BadNumberOfParametersErrorCode, UndefinedFunctionCallError: UndefinedFunctionCallErrorCode, UnaryOperatorTypeError: UnaryOperatorTypeErrorCode, UnknownDataTypeError: UnknownDataTypeErrorCode, UnknownStatementError: UnknownStatementErrorCode, IllegalVariableDeclarationError: IllegalVariableDeclarationErrorCode, IllegalFunctionSignatureError: IllegalFunctionSignatureErrorCode, IllegalNestedClassesError: IllegalNestedClassesErrorCode, InvalidStatementPlacementError: InvalidStatementPlacementErrorCode, DuplicatePackageImportError: DuplicatePackageImportErrorCode, OutsideConstructorCallError: OutsideConstructorCallErrorCode, InvalidClassAccessError: InvalidClassAccessErrorCode, IllegalConstructorCallError: IllegalConstructorCallErrorCode, TernaryOperatorTypeError: TernaryOperatorTypeErrorCode, UnknownClassError: UnknownClassErrorCode, FunctionAccessViolationError: FunctionAccessViolationErrorCode, UnknownFieldError: UnknownFieldErrorCode, InvalidNumberOfSubtypesError: InvalidNumberOfSubtypesErrorCode, UnknownPackageError: UnknownPackageErrorCode, UnknownVTableError: UnknownVTableErrorCode, UnknownConstructorError: UnknownConstructorErrorCode, UnknownPackageModuleFileError: UnknownPackageModuleFileErrorCode, IllegalBoxedTypeError: IllegalBoxedTypeErrorCode, IllegalUnspecificArrayTypeError: IllegalUnspecificArrayTypeErrorCode, MonkeError: MonkeErrorCode, InvalidNonPointerReferenceError: InvalidNonPointerReferenceErrorCode, UnparsableFingerprintError: UnparsableFingerprintErrorCode, UnexpectedNonArrayValueError: UnexpectedNonArrayValueErrorCode, ImpossibleFunctionProcessingError: ImpossibleFunctionProcessingErrorCode, ImpossibleFieldProcessingError: ImpossibleFieldProcessingErrorCode, FileAlreadyInSourcesWarning: FileAlreadyInSourcesWarningCode, InvalidExternalFunctionPlacementError: InvalidExternalFunctionPlacementErrorCode, UnexpectedNonPointerValueError: UnexpectedNonPointerValueErrorCode, UnknownStructError: UnknownStructErrorCode, TooManyStructParametersError: TooManyStructParametersErrorCode, CAdapterCompilationError: CAdapterCompilationErrorCode, ExternalCAdapterWarning: ExternalCAdapterWarningCode, OutsideThisError: OutsideThisErrorCode, }
var OutputErrorMessages = true
var SourceFiles = make(map[string]string)
Functions ¶
func CrashIfErrorsFound ¶
func CrashIfErrorsFound()
func Error ¶
Error prints custom error message and code snippet to terminal/console Uses old colour formatting method, will switch to Format() later
func Format ¶
Format multiline coloring made easier! use colour codes in the string like "&pHello gamers, %rHow are you doing today&dgr?" and Format will colour code it for you. the defaultColour will be the default colour of text if it is not coloured also doing the same colour code will reset the colour e.g. "Hello, &rW&rorld!" only "W" will be red
func PrintCodeSnippet ¶
func PrintCodeSnippet(span TextSpan)
PrintCodeSnippet does what it says on the label, it prints a snippet of the code in CodeReference.
func PrintCodeSnippetS ¶
PrintCodeSnippetS returns a code snippet string instead of returning it like PrintCodeSnippet.
func PrintLineOfCode ¶
Types ¶
type ErrorCode ¶
type ErrorCode int
ErrorCode the numerical representation of an Error, this allows it to be "looked up" using the Error lookup system. Each ErrorCode increments by 1 per declaration. ErrorCodes are also given additional values depending on the section they come from. For example, Errors from the binder have a default value of 3000, this value it added onto the iota increment to produce the specific ErrorCode.
type ErrorReport ¶
type ErrorReport struct { Area string ErrType ErrorType Span TextSpan Message string MessageArgs []interface{} }
ErrorReport is a structure to hold all info about an error
type ErrorType ¶
type ErrorType string
ErrorType stores the string value of errors, it's helpful to have all the error in one place.