All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Show unreleased changes
Note that all changes categorised under Unreleased are UNSTABLE changes, which MAY be released in the next version. These should not be considered guaranteed changes for the next release of Kipper.
To use development versions of Kipper download the
next
tag release, which will include the specified changes.
0.12.0 - 2024-09-25
- Support for dot notation for accessing properties of objects. (#67)
- Support for classes, class methods, class properties and class constructors. (#665)
- Support for object literals and object properties. (#526)
- Support for calling lambdas and functions stored in variables or expressions. (#674)
- Semantic checking and code generation for the
new
keyword expression to be able to create new instances of classes. (#679) - Support for the
this
keyword inside a class method to access the current instance of the class. (#697) - Support for the typeof operator, which returns the runtime type of a value. (#663)
- Implemented
instanceof
operator expression, which checks if an object is an instance of a class. (#686) - Implemented
matches
operator expression, which checks if an object matches an interface. (#672) - Implemented the generic
Array<T>
type and single-type array initializers. (#499) - Support for index-based array assignments. (#669)
- Implemented the generic
Func<T..., R>
type and function type initializers. (#584) - Implemented internal generic spread argument
T...
, which allows multiple arguments to be passed to a single parameter inside a generic type specifier. - Implemented constant
NaN
, which represents theNaN
value in JavaScript (Not a Number). (#671) - Support for Nix Flakes and direnv, which allows for a more reproducible and consistent development environment.
- Support for internal type unions in built-in and internal functions. (#496)
- Support for the
obj
type translation to TypeScript. - Implemented internal representation for custom types such as objects, interfaces and classes. This change means that the entire core type system has been reworked and adjusted to also support custom types as well as complex types (objects, arrays etc.). This does not inherently add functionality but serves as the stepping stone for the implementation of all custom types in the future. (#524)
- Implemented internal preliminary type checking and "ahead of time" type evaluation to allow for self-referential types and type checking of recursive types.
- New module:
semantics/runtime-built-ins
, which contains runtime built-in functions, variables and types.semantics/runtime-internals
, which contains the runtime internal functions.semantics/types
, which contains the runtime types.
- New classes:
NewInstantiationExpression
, which represents an AST new instantiation expression.TypeofExpression
, which represents an AST typeof expression that returns the runtime type of an object.TypeofTypeSpecifierExpression
, which represents an AST typeof type specifier that lets one define a type by using an object as referenceBuiltInTypeObject
, which is the base class for the compilers representation of runtime objectsUniverseScope
, which represents the universe scope, where all built-in types, functions and variables are declared. This serves as the parent of the global scope.InterfaceDeclaration
, which represents an AST interface declaration.ClassMethodDeclaration
, which represents an AST class method declaration.ClassPropertyDeclaration
, which represents an AST class property declaration.ClassConstructorDeclaration
, which represents an AST class constructor.ClassDeclaration
, which represents an AST class declaration.BuiltInType
, which represents a built-in type.CustomType
, which represents a user defined type.UnionType
, which represents a union type.BuiltInTypeAny
, which represents theany
type.BuiltInTypeVoid
, which represents thevoid
type.BuiltInTypeNull
, which represents thenull
type.BuiltInTypeUndefined
, which represents theundefined
type.BuiltInTypeBool
, which represents thebool
type.BuiltInTypeNum
, which represents thenum
type.BuiltInTypeStr
, which represents thestr
type.BuiltInTypeArray
, which represents theArray<T>
type.BuiltInTypeFunc
, which represents theFunc<T..., R>
type.BuiltInTypeObj
, which represents theobj
type.ScopeTypeDeclaration
, which represents a scope type declaration.CustomType
, which is a class extending fromProcessedType
and implementing the functionality for a custom type such as an interface or class.UserScope
, which represents a user scope i.e. any scope except the universe scope.ClassScopeThisDeclaration
, which represents thethis
declaration of a class.InstanceOfExpression
, which represents theinstanceof
operator expression.MatchesExpression
, which represents thematches
operator expression.
- New errors:
TypeCanNotBeUsedForTypeCheckingError
, which is thrown when a type is used for type checking, but is not a valid type. This is an error indicating an invalid logic that should be fixed.GenericArgumentTypeError
, which is thrown when a generic argument is used with an invalid type. This is an error indicating an invalid logic that should be fixed.InvalidAmountOfGenericArgumentsError
, which is thrown when an invalid amount of generic arguments is used. This is an error indicating an invalid logic that should be fixed.CanNotUseNonGenericAsGenericTypeError
, which is thrown when a non-generic type is used as a generic type. This is an error indicating an invalid logic that should be fixed.MismatchingArgCountBetweenFuncTypesError
, which is thrown when the amount of arguments in a function type does not match the number of arguments in the function type it is compared to.GenericCanOnlyHaveOneSpreadError
, which is thrown when a generic type has more than one spread argument. This is for now an internal-only error that should not be thrown in normal circumstances.TypeNotAssignableToUnionError
, which is thrown when a type is not assignable to a union type.ValueTypeNotIndexableWithGivenAccessor
, which is thrown when a value type is not indexable with the given accessor.PropertyDoesNotExistError
, which is thrown when a property does not exist on a type.DuplicateUniverseKeyError
, which is thrown when a key is duplicated in the universe scope.IdentifierAlreadyUsedByMemberError
, which is thrown when an identifier is already used by another property.InvalidInstanceOfTypeError
, which is thrown when theinstanceof
operator is used with a type other than a class.InvalidMatchesTypeError
, which is thrown when thematches
operator is used with a type other than an interface.
- New interfaces and types:
InterfaceDeclarationSemantics
, which represents the semantics of an interface declaration.InterfaceDeclarationTypeSemantics
, which represents the type semantics of an interface declaration.ClassMethodDeclarationSemantics
, which represents the semantics of a class method declaration.ClassMethodDeclarationTypeSemantics
, which represents the type semantics of a class method declaration.ClassPropertyDeclarationSemantics
, which represents the semantics of a class property declaration.ClassPropertyDeclarationTypeSemantics
, which represents the type semantics of a class property declaration.ClassConstructorDeclarationSemantics
, which represents the semantics of a class constructor declaration.ClassConstructorDeclarationTypeSemantics
, which represents the type semantics of a class constructor declaration.ClassDeclarationSemantics
, which represents the semantics of a class declaration.ClassDeclarationTypeSemantics
, which represents the type semantics of a class declaration.TypeDeclaration
, which represents a type declaration. This is an abstract base class for all type declarations.TypeDeclarationSemantics
, which represents the semantics of a type declaration.TypeDeclarationTyp
KipperTypeChecker.validArrayExpressioneSemantics
, which represents the type semantics of a type declaration.CompilableType
, which represents a type that can be compiled.BuiltInReference
, which replaces the now removed typeReference
in theKipperProgramContext
for reference tracking of built-in types.NewInstantiationExpressionSemantics
, which represents the semantics of a new instantiation expression.NewInstantiationExpressionTypeSemantics
, which represents the type semantics of a new instantiation expression.TypeofExpressionSemantics
, which represents the semantics of a typeof expression.TypeofExpressionTypeSemantics
, which represents the type semantics of a typeof expression.KipperCallable
, which is an alias forFunctionDeclaration
,LambdaPrimaryExpression
andClassMethodDeclaration
.TypeDeclarationPropertyTypeSemantics
, which represents the type semantics of a type declaration property.InstanceOfExpressionSemantics
, which represents the semantics of an instanceof expression.InstanceOfExpressionTypeSemantics
, which represents the type semantics of an instanceof expression.MatchesExpressionSemantics
, which represents the semantics of a matches expression.MatchesExpressionTypeSemantics
, which represents the type semantics of a matches expression.
- New functions:
KipperTypeChecker.validArrayExpression()
, which ensures that an array expression is valid.KipperTypeChecker.validInstanceofClassType()
, which ensures that aninstanceof
expression is valid for a class.KipperTypeChecker.validMatchesInterfaceType()
, which ensures that amatches
expression is valid for an interface.ClassDeclaration.getThis()
, which returns thethis
type of the class.ClassScope.getThis()
, which returns thethis
type of the class. This is a simple alias for the method in theClassDeclaration
class.JavaScriptTargetCodeGenerator.generateInterfaceRuntimeTypeChecks()
which generates runtime type checks for an interface.getRuntimeType()
, which gets the corresponding runtime representation of a built-in type.
- New properties:
BuiltInFunction.funcType
, which returns a function type for the built-in function.FunctionDeclarationTypeSemantics.type
, which returns the type of the function declaration i.e. the function type.LambdaPrimaryExpressionTypeSemantics.type
, which returns the type of the lambda primary expression i.e. the function type.FunctionCallExpressionTypeSemantics.funcOrExp
, which returns the function or expression that is called. This always stores some sort of value that extendsBuiltInTypeFunc
.CustomType.clsExtends
, which returns the class that the custom type extends. This is only applicable for classes.CustomType.clsImplements
, which returns the interfaces that the custom type implements. This is only applicable for classes.CustomType.intfExtends
, which returns the interfaces that the custom type extends. This is only applicable for interfaces.CustomType._clsStaticFields
, which returns the static fields of the custom type. This is only applicable for classes.ASTNode.preliminaryTypeSemantics
, which runs the preliminary type semantics of the node as well as the preliminary type semantics of all its children. This is a recursive function.ASTNode.primaryPreliminaryTypeSemantics
, which returns the primary preliminary type semantics of the node. May be undefined if there is no primary preliminary type semantics for the given node.
- New runtime error
KipperError
, which serves as the base forTypeError
andIndexError
.
- Argument type of built-in function
print
fromstr
toany
. - Argument type of built-in function
len
fromstr
tostr | Array<any>
. (#667) - Type from interface to class:
InternalFunction
, which represents an internal function.BuiltInFunction
, which represents a built-in function.InternalFunctionArgument
, which represents an internal function argument.BuiltInVariable
, which represents a built-in variable.
- Renamed:
- Module
analysis
tosemantics
. - Module
compiler/.../expressions/arithmetic
toarithmetic-expression
. - Class
UncheckedType
toRawType
. - Class
CheckedType
toProcessedType
. - Class
UndefinedCustomType
toUndefinedType
. - Method
KipperProgramContext._initUniversalReferencables()
to_initUniversalReferenceables()
.
- Module
- All functions and lambdas simply resolving to
Func
instead of the appropriate filled-upFunc<T..., R>
type. This now enables proper type checking for function references. - CLI command
run
not properly reporting internal or unexpected errors, as they were already prettified in the internally called up commandcompile
. - Previously invalid parent type checking and evaluation performed in
ReturnStatement
. This was now made absolute by the introduction of the preliminary type checking and "ahead of time" type evaluation, as that now allows for self-referential types and type checking of recursive types i.e. the return statement now knows the type of its function even though it is not yet fully processed. - Duplicate universe entry registration in the
KipperProgramContext
for built-in types, functions and variables. - Bug where lambda compound bodies would cause a syntax error, despite being a valid lambda body.
- Type
Reference
as it is no longer needed and has been replaced byKipperReferenceable
. - Function
FunctionCallExpressionTypeSemantics.func
, which is now has been replaced byfuncOrExp
. - Function
KipperProgramContext.setUpBuiltInsInGlobalScope()
, which is no longer needed as the universe scope now handles all built-in types, functions and variables.
0.11.0 - 2024-07-10
- Implemented Processing for File Scoped pragmas (#480)
- Added Lambda Expressions, which are anonymous functions that can be used as expressions. (#572)
- Implemented Bitwise Operations (
&
,|
,^
,~
,<<
,>>
,>>>
). (#493) - Implemented Conditional Expression (
COND ? EXP : EXP
) as a ternary operator. (#534) - Implemented Do-While-Loop (
do ... while ...
) iteration statements. (#271) - Support for config files with a new monorepo package called
@kipper/config
, which implements config file loading and parsing. This package is used by the Kipper CLI to automatically load and parse config files. (#502). - Added setup wizard to the
@kipper/cli
to automatically create a Kipper project with a config file. (#502). - Support for complex string formatting (or also called templating) in the form of Python-like F-Strings. (#287).
- Support for string multiplication using the
*
operator. (#478). - New CLI flag
--dry-run
incompile
, which only compiles the program and does not write any outputs. (#532). - New valid conversions:
void
tostr
.null
tostr
.undefined
tostr
.
- New modules:
kipper/core/tools
, which contains all tools and utilities used by the compiler.kipper/core/tools/decorators
, which contains all decorators used by the compiler.kipper/core/tools/functions
, which contains all functions used by the compiler.kipper/core/tools/types
, which contains all types used by the compiler.kipper/core/compiler/ast/common
, which contains commonly used types and functions.kipper/core/compiler/ast/factories
, which replaces the old filefactories.ts
and contains all AST factory classes and types.kipper/core/compiler/ast/mapping
, which contains all AST mapping objects and theASTNodeMapper
class.
- New classes:
ASTNodeMapper
, which handles the mapping between kind numbers, rule names, AST classes and parser context classes.PrimaryExpression
, which is an abstract base class for all primary expressions.PostfixExpression
, which is an abstract base class for all postfix expressions.PromptModule
in@kipper/cli
, which contains all prompt-related functions and classes.ObjectPrimaryExpression
, which represents an AST object primary expression.ObjectProperty
, which represents an AST object property.BitwiseExpression
, which represents an AST bitwise expression.BitwiseAndExpression
, which represents an AST bitwise AND expression.BitwiseOrExpression
, which represents an AST bitwise OR expression.BitwiseXorExpression
, which represents an AST bitwise XOR expression.BitwiseShiftExpression
, which represents an AST bitwise shift expression.LambdaExpression
, which represents an AST lambda expression.PragmaProcessor
which handles the processing of all possible Pragmas.
- New interfaces:
LambdaExpressionSemantics
, which represents the semantics of a lambda expression.LambdaExpressionTypeSemantics
, which represents the type semantics of a lambda expression.PrimaryExpressionSemantics
, which represents the semantics of a primary expression.PrimaryExpressionTypeSemantics
, which represents the type semantics of a primary expression.PostfixExpressionSemantics
, which represents the semantics of a postfix expression.PostfixExpressionTypeSemantics
, which represents the type semantics of a postfix expression.IterationStatementTypeSemantics
, which represents the type semantics of an iteration statement.ExpressionStatementSemantics
, which represents the semantics of an expression statement.ExpressionStatementTypeSemantics
, which represents the type semantics of an expression statement.StatementSemantics
, which represents the semantics of a statement.StatementTypeSemantics
, which represents the type semantics of a statement.IfStatementTypeSemantics
, which represents the type semantics of an if statement.CompoundStatementSemantics
, which represents the semantics of a compound statement.CompoundStatementTypeSemantics
, which represents the type semantics of a compound statement.ForLoopStatementTypeSemantics
, which represents the type semantics of a for loop statement.DoWhileLoopIterationStatementTypeSemantics
, which represents the type semantics of a do-while loop statement.WhileLoopStatementTypeSemantics
, which represents the type semantics of a while loop statement.JumpStatementTypeSemantics
, which represents the type semantics of a jump statement.SwitchStatementSemantics
, which represents the semantics of a switch statement.SwitchStatementTypeSemantics
, which represents the type semantics of a switch statement.ObjectPrimaryExpressionSemantics
, which represents the semantics of an object primary expression.ObjectPrimaryExpressionTypeSemantics
, which represents the type semantics of an object primary expression.ObjectPropertySemantics
, which represents the semantics of an object property.ObjectPropertyTypeSemantics
, which represents the type semantics of an object property.BitwiseExpressionSemantics
, which represents the semantics of a bitwise expression.BitwiseExpressionTypeSemantics
, which represents the type semantics of a bitwise expression.BitwiseAndExpressionSemantics
, which represents the semantics of a bitwise AND expression.BitwiseAndExpressionTypeSemantics
, which represents the type semantics of a bitwise AND expression.BitwiseOrExpressionSemantics
, which represents the semantics of a bitwise OR expression.BitwiseOrExpressionTypeSemantics
, which represents the type semantics of a bitwise OR expression.BitwiseXorExpressionSemantics
, which represents the semantics of a bitwise XOR expression.BitwiseXorExpressionTypeSemantics
, which represents the type semantics of a bitwise XOR expression.BitwiseShiftExpressionSemantics
, which represents the semantics of a bitwise shift expression.BitwiseShiftExpressionTypeSemantics
, which represents the type semantics of a bitwise shift expression.
- New parameters:
ignoreParams
ingenJSFunction()
, which, if true makes the function signature define no parameters.ignoreParams
increateJSFunctionSignature()
, which, if true makes the function signature define no parameters.ignoreParams
ingenTSFunction()
, which, if true makes the function signature define no parameters.ignoreParams
increateTSFunctionSignature()
, which, if true makes the function signature define no parameters.
- New constants:
DEFAULT_TOKEN_CHANNEL
, which is the channel id of the default channel storing all the parser-relevant tokens that the Lexer lexed.HIDDEN
, which is the channel id of the channel storing all whitespaces and newlines that the Lexer lexed.COMMENT
, which is the channel id of the channel storing all the comments that the Lexer lexed.PRAGMA
, which is the channel id of the channel storing all pragma comments that the Lexer lexed.
- New fields:
KipperError.programCtx
, which contains, ifKipperError.tracebackData.errorNode
is not undefined, the program context of the error.ParserASTNode.ruleName
, which contains the rule name of the node.LexerParserData.channels
, which stores the channels generated by the Lexer.
- New types:
InverseMap
, which inverts a map by swapping the keys and values.
- New functions:
KipperTargetBuiltInGenerator.voidToStr()
, for the built-in conversion fromvoid
tostr
.KipperTargetBuiltInGenerator.nullToStr()
, for the built-in conversion fromnull
tostr
.KipperTargetBuiltInGenerator.undefinedToStr()
, for the built-in conversion fromundefined
tostr
.replaceObjKeys()
, which replaces the keys of an object with the values returned by a function.inverseMap()
, which inverts a map by swapping the keys and values.loadConfig()
in@kipper/cli
, which loads a config file from the specified path.loadAutoConfig()
in@kipper/cli
, which loads a config file from the current working directory.copyConfigResources()
in@kipper/cli
, which copies the resources from the config file to the output directory.KipperTypeChecker.validConditionalExpression()
, which ensures that a conditional expression is valid.PragmaProcessor.processSingleLine()
, which changes the compiler options according to the pragmas found in the file.
- Fixed bug allowing the use of any expressions for call expressions as that is not implemented yet.
- Standardised error output for the CLI as described in #435.
(This is the same change as in
0.10.3
, but was only added to the dev branch with the release of0.11.0-alpha.1
i.e.0.11.0-alpha.0
does not have this change). - Made
VoidOrNullOrUndefinedPrimaryExpression
a constant expression and inherit from theConstantExpression
class. This means it's AST kind number is now also added to theASTConstantExpressionKind
type and its context class is also part of theParserConstantExpressionContext
type. - Renamed:
- Module
compiler/parser
tolexer-parser
. - File
kipper/core/compiler/parser/parser-ast-mapping.ts
toparse-rule-kind-mappings.ts
. - Class
KipperParseStream
toKipperFileStream
including its file tofile-stream.ts
. - CLI Class
KipperParseFile
toKipperInputFile
including its file toinput-file.ts
. - Class
FunctionCallPostfixTypeSemantics
toFunctionCallExpressionTypeSemantics
. - Field
FStringPrimaryExpressionSemantics.items
toatoms
. - Function
getTSFunction()
togenTSFunction()
. - Grammar Rule
typeSpecifier
totypeSpecifierExpression
and its AST classTypeSpecifier
toTypeSpecifierExpression
. This also includes changing the name in theKipperTargetCodeGenerator
,KipperTargetSemanticAnalyser
andKipperTargetBuiltInGenerator
classes. - Grammar Rule
identifierTypeSpecifier
toidentifierTypeSpecifierExpression
and its AST classIdentifierTypeSpecifier
toIdentifierTypeSpecifierExpression
. This also includes changing the name in theKipperTargetCodeGenerator
,KipperTargetSemanticAnalyser
andKipperTargetBuiltInGenerator
classes. - Grammar Rule
genericTypeSpecifier
togenericTypeSpecifierExpression
and its AST classGenericTypeSpecifier
toGenericTypeSpecifierExpression
. This also includes changing the name in theKipperTargetCodeGenerator
,KipperTargetSemanticAnalyser
andKipperTargetBuiltInGenerator
classes. - Grammar Rule
typeofTypeSpecifier
totypeofTypeSpecifierExpression
and its AST classTypeofTypeSpecifier
toTypeofTypeSpecifierExpression
. This also includes changing the name in theKipperTargetCodeGenerator
,KipperTargetSemanticAnalyser
andKipperTargetBuiltInGenerator
classes. - Grammar Rule
forLoopStatement
toforLoopIterationStatement
and its AST classForLoopStatement
toForLoopIterationStatement
. This also includes changing the name in theKipperTargetCodeGenerator
,KipperTargetSemanticAnalyser
andKipperTargetBuiltInGenerator
classes. - Grammar Rule
whileLoopStatement
towhileLoopIterationStatement
and its AST classWhileLoopStatement
toWhileLoopIterationStatement
. This also includes changing the name in theKipperTargetCodeGenerator
,KipperTargetSemanticAnalyser
andKipperTargetBuiltInGenerator
classes. - Grammar Rule
doWhileLoopStatement
todoWhileLoopIterationStatement
and its AST classDoWhileLoopStatement
toDoWhileLoopIterationStatement
. This also includes changing the name in theKipperTargetCodeGenerator
,KipperTargetSemanticAnalyser
andKipperTargetBuiltInGenerator
classes. - File
kipper/core/compiler/parser/parser-ast-mapping.ts
toparse-rule-kind-mappings.ts
. - Class
ArrayLiteralPrimaryExpression
toArrayPrimaryExpression
. - Interface
ArrayLiteralPrimaryExpressionSemantics
toArrayPrimaryExpressionSemantics
. - Interface
ArrayLiteralPrimaryExpressionTypeSemantics
toArrayPrimaryExpressionTypeSemantics
. - Interface
TangledPrimaryTypeSemantics
toTangledPrimaryExpressionTypeSemantics
. - Interface
DoWhileLoopStatementSemantics
toDoWhileLoopIterationStatementSemantics
. - Interface
ParseData
toLexerParserData
. - Method
TargetASTNodeCodeGenerator.arrayLiteralExpression
toarrayPrimaryExpression
. - Method
TargetASTNodeSemanticAnalyser.listPrimaryExpression
toarrayPrimaryExpression
. - Field
FStringPrimaryExpressionSemantics.items
toatoms
. - Field
LexerParserData.parseStream
tofileStream
.
- Module
- Moved:
kipper/core/utils.ts
tokipper/core/tools
and separated it into multiple files & modules.kipper/core/compiler/ast/root-ast-node.ts
to thekipper/core/compiler/ast/nodes
module.kipper/core/compiler/ast/ast-types.ts
to the newkipper/core/compiler/ast/common
module.
- Redeclaration bug causing an
InternalError
after calling the compiler (#462). - Compiler argument bug in
KipperCompiler
, whereabortOnFirstError
didn't precederecover
, meaning that instead of an error being thrown the failed result was returned (As defined in therecover
behaviour, which is incorrect). - Bug of invalid underline indent in error traceback. (#434).
- CLI bug where the
-t
shortcut flag was incorrectly shown for the commandhelp compile
. (#451) (This is the same fix as in0.10.3
, but was only added to the dev branch with the release of0.11.0-alpha.1
i.e.0.11.0-alpha.0
still has this bug). - CLI error handling bug as described in #491. This includes
multiple bugs where errors were reported as "Unexpected CLI Error". (This is the same fix as in
0.10.4
, but with one additional edge-case covered. This fix was only added to the dev branch with the release of0.11.0-alpha.1
i.e.0.11.0-alpha.0
still has this bug).
- Removed deprecated flag
--abort-on-first-error
in favour of--no-recover
. (#501). - Removed CLI command
analyse
in favor of the flag--dry-run
in the CLI commandcompile
. (#532). - Removed AST parent class
ConstantExpression
, its interfacesConstantExpressionSemantics
andConstantExpressionTypeSemantics
, as they were not really needed and unnecessarily added another level of complexity to the AST. All classes which previously inherited fromConstantExpression
now inherit fromPrimaryExpression
instead.
0.10.4 - 2023-08-15
- Moved function
executeKipperProgram
toRun
as a private function. - Moved class
KipperCompileResult
to new filecompile-result.ts
in the same directory. - Field
KipperCompileResult.programCtx
can now be alsoundefined
, due to the changed behaviour that now aKipperCompileResult
is also returned for syntax errors (where it has no value).
- CLI error handling bug as described in #491. This includes multiple bugs where errors were reported as "Unexpected CLI Error".
- CLI flag
--abort-on-first-error
in favour of--no-recover
. #501.
0.10.3 - 2023-07-22
- New modules in
@kipper/cli
:input
, which contains all input-related handling functions and classes.output
, which contains the output-related handling functions and classes.
- New decorator
prettifiedErrors
in@kipper/cli
, which applies standardised error formatting to any thrown error.
- Standardised error output for the CLI as described in #435.
- Error message of
KipperInternalError
, which does not have " - Report this bug to the developer using the traceback!" as a suffix anymore. - Changed success message of the
kipper analyse
commandFinished code analysis in ...
toDone in ...
. - Renamed
getFile
togetParseStream
.
- CLI bug where the
-t
shortcut flag was incorrectly shown for the commandhelp compile
. (#451)
0.10.2 - 2023-06-16
- New field:
KipperError.programCtx
, which contains, ifKipperError.tracebackData.errorNode
is not undefined, the program context of the error.
- New function:
ensureScopeDeclarationAvailableIfNeeded
, which ensures that a scope declaration is available if needed. This is used during the semantic analysis/type checking of a declaration statement, which may need the scope declaration object during the processing.
- Redeclaration bug causing an
InternalError
after calling the compiler (#462). - Compiler argument bug in
KipperCompiler
, whereabortOnFirstError
didn't precederecover
, meaning that instead of an error being thrown the failed result was returned (As defined in therecover
behaviour, which is incorrect). - Bug of invalid underline indent in error traceback. (#434).
0.10.1 - 2023-02-21
- Bug causing the compiler to not detect the expected useless statement warning for a useless arithmetic expression. (#426).
0.10.0 - 2023-02-19
- Added full support for custom-defined functions, function arguments, function return evaluation, function scopes/argument referencing and return-value code branch inspection. (#183).
- Implemented while-loop iteration statements (#268).
- Implemented for-loop iteration statements (#270).
- JavaScript compilation target with a new monorepo package called
@kipper/target-js
, which implements the semantic analysis and code generation for JavaScript, and provides the classKipperJavaScriptTarget
(TargetTS
available as alias), which can be used as the target in theCompileConfig
. (#208). - Standalone web-module package called
@kipper/web
, which from now on will provide thekipper-standalone.js
script that can be used in a web-application. This also bundles@kipper/target-js
and@kipper/target-ts
, which can be also accessed using the identifiersKipperJS
andKipperTS
in the web environment. (#86). - Implemented arithmetic assignment operators
+=
,-=
,*=
,%=
and/=
(#273). - Support for unary and postfix increment and decrement (
++
,--
) expressions (#272). - Implemented member-access expressions using bracket and slice notation (
[]
,[:]
), which can be used to access specific elements of a string (In the future, this will also be used to access elements of arrays and objects). (#372). - Support for single-line comments separated by a newline char. (#400).
- Implemented new built-in function
len()
, which returns the length of a string (In the future also arrays). (#411). - Support for jump statements
continue
andbreak
for iteration statements. (#269). - New built-in variable
__name__
returning the name of the current file. This also includes general support for built-in variables in the compiler. (#412). - New built-in Kipper type
null
andundefined
, and support for the constant identifiervoid
,null
andundefined
. - Finished implementation of warning reporting system and added warning for useless expression statements. (#413).
- New Kipper CLI flag
-t/--target
to specify the target to use for a compilation or execution. - Use of
"use strict";
in the TypeScript target to enforce the use of strict mode during runtime. - New generic parameter
TypeSemantics
toASTNode
, which defines the type data that the AST Node should evaluate during type checking. - New CLI flags for commands
run
andcompile
:--log-timestamp
, which enables timestamps for the log messages.--recover
, which enables error recovery for the Kipper compiler.--abort-on-first-error
, which aborts the compilation on the first compiler error that is encountered.
- New errors/warnings:
MissingFunctionBodyError
, which is thrown when a function declaration is missing a body (compound statement).LexerOrParserSyntaxError
, which is thrown when the lexer or parser encounters a syntax error.IdentifierAlreadyUsedByParameterError
, which is thrown when an identifier is already used by a parameter in the same scope or any parent scope.ExpressionNotCallableError
, which is thrown when an expression is not callable, despite it being used in a call expression.IncompleteReturnsInCodePathsError
, which is thrown whenever a non-void function has code paths that do not return a value.ReturnStatementError
, which is thrown whenever a return statement is used outside a function.InvalidUnaryExpressionOperandError
, which is thrown whenever a unary expression is used with an invalid operand.UndefinedDeclarationCtxError
, which is thrown when the declaration context of a declaration is undefined. (This is an internal error that happens if the declaration context is accessed too early e.g. before its creation.)TypeNotCompilableError
, which is thrown when an invalid/undefined type is cast to a compilable type, despite it being invalid. (This is an internal error that happens if the type is cast during compilation despite it having errored during semantic analysis/type checking.)InvalidKeyTypeError
, which is thrown when an expression with an invalid type is used as a key/index to access an object-like or array-like.ValueNotIndexableTypeError
, which is thrown when a value is not indexable (not object-like), despite it being used in a member access expression.MissingRequiredSemanticDataError
, which is a specific internal error used to indicate that a specified node is missing required semantic data from another node and as a result failed to process itself.UselessExpressionStatementWarning
, which is reported when an expression statement is used without any side-effects and as such does not have any effect on the program.
- New classes/interfaces:
KipperWarning
, which is a subclass ofKipperError
that is used to indicate a warning. This replaces the use ofKipperError
for warnings.ReturnStatement
, which is a subclass ofStatement
that represents a return statement. This is not anymore included in theJumpStatement
class.FunctionScope
, which is a subclass ofScope
that represents a function scope with registered parameters.UndefinedCustomType
, which represents an invalid/undefined type that was created by the user, but is not defined in the program. This is used to allow error recovery and continue even with an invalid type during type checking, and let the type checker know to ignore type checks with references of this type.Type
, which is an abstract base class for defining a wrapper class for a Kipper type during semantic analysis and type checking.UncheckedType
, which is an implementation ofType
and represents a raw specified type during semantic analysis.CheckedType
, which is an implementation ofType
and represents a checked type during type checking, which also handles compatibility and error recovery for undefined types.MemberAccessExpression
, which is a subclass ofExpression
that represents a member access expression (Antlr4 rulememberAccessExpression
).AnalysableASTNode
, which represents an AST node that can be semantically processed. This class was created as a parent class forCompilableASTNode
, as a way to split up the semantic analysis and code generation.KipperWarningIssuer
, which is a class similar toKipperSemanticChecker
and checks for certain conditions and reports warnings if they are met.ScopeNode<T>
, which is an interface representing an AST node that implements its own local scope. This means that the definitions of its children, will be stored in theinnerScope
field of the class implementation.SymbolTable
, which implements the basic functionality of a symbol table containing the metadata for a scope.MemberAccessExpressionSemantics
, which represents the semantics forMemberAccessExpression
.MemberAccessExpressionTypeSemantics
, which represents the type semantics forMemberAccessExpression
.TargetAnalysableNode
, which represents an AST node that has a target-specific semantic analysis function.TargetCompilableNode
, which represents an AST node that has a target-specific code generation function.ASTNodeFactory
, which represents a basic factory for creating AST nodes.InternalFunctionArgument
, which represents an internal function argument.InternalReference<T>
, which represents an indirect reference to an internal function by the user. This is primarily used to keep track of the internal functions that are used in the program, and to generate them in the target code.
- New functions:
KipperTargetCodeGenerator.setUp()
, which should generate SetUp code for the specified target.KipperTargetCodeGenerator.wrapUp()
, which should generate WrapUp code for the specified target.ASTNode.getTypeSemanticData()
, which returns the type semantics if they are defined, otherwise throws anUndefinedSemanticsError
.CompilableASTNode.semanticTypeChecking()
, which performs type checking for the AST node and its children nodes. This is called in the functionRootASTNode.semanticAnalysis
afterCompilableASTNode.semanticAnalysis()
.CompilableASTNode.wrapUpSemanticAnalysis()
, which performs wrap-up semantic analysis for the target of the AST node. This is called in the functionRootASTNode.semanticAnalysis
afterCompilableASTNode.semanticTypeChecking()
.Scope.getReferenceRecursively()
, which tries to evaluate a reference recursively in the scope and its parent scopes.KipperTypeChecker.validReturnStatement()
, which ensures that a return statement is only used inside a function.KipperTypeChecker.checkMatchingTypes()
, which checks if the two specified types are matching.KipperTypeChecker.referenceCallable()
, which asserts that the specified reference is a callable function.KipperTypeChecker.validReturnCodePathsInFunctionBody()
, which ensures that all code paths of a non-void function return a proper value.KipperSemanticChecker.identifierNotUsed()
, which asserts that the specified identifier is unused in the specified scope and can be used for a new declaration.KipperSemanticChecker.getReturnStatementParent()
, which evaluates the parent function for a return statement.KipperSemanticChecker.refTargetDefined()
, which asserts that the specified reference is defined and can be used.KipperSemanticChecker.validFunctionBody()
, which ensures the body of a function is a compound statement.CompilableASTNode.addError()
, which adds an error to the list of errors caused by the node.removeBraces()
for removing braces due to formatting reasons.CompilableASTNode.recursivelyCheckForWarnings()
, which recursively calls all children'scheckforWarnings()
functions as well as the function of the parent instance.shouldRecoverFromError()
andhandleSemanticError()
inhandle-error.ts
.AnalysableASTNode.semanticallyAnalyseChildren()
, which semantically analyses all children nodes of the AST node.AnalysableASTNode.semanticallyTypeCheckChildren()
, which semantically type checks all children nodes of the AST node.AnalysableASTNode.targetSemanticallyAnalyseChildren()
, which semantically analyses all children nodes of the AST node for the target.AnalysableASTNode.ensureSemanticallyValid()
, which throws aMissingRequiredSemanticDataError
in case that the specified node failed during semantic analysis. This is used by other nodes to ensure that the node is valid and its data can be safely accessed.AnalysableASTNode.ensureTypeSemanticallyValid()
, which throws aMissingRequiredSemanticDataError
in case that the specified node failed during type checking. This is used by other nodes to ensure that the node is valid and its data can be safely accessed.KipperSemanticChecker.getJumpStatementParent()
, which evaluates the parent iteration statement for a jump statement.KipperProgramContext.registerBuiltInFunctions()
, which registers one or more built-in functions.KipperProgramContext.registerBuiltInVariables()
, which registers one or more built-in variables.KipperProgramContext.clearBuiltInFunctions()
, which clears the list of built-in functions.KipperProgramContext.clearBuiltInVariables()
, which clears the list of built-in variables.KipperProgramContext.getBuiltInVariable()
, which returns the built-in variable with the specified name if found.KipperProgramContext.builtInFunctionReferences
, which stores all the references to built-in functions.KipperProgramContext.builtInVariableReferences
, which stores all the references to built-in variables.
- New types:
TypeData
, which represents the type data of anASTNode
.NoTypeSemantics
, which hints that anASTNode
has no type semantic data.TargetSetUpCodeGenerator
, which represents a function that generates SetUp code for a Kipper file.TargetWrapUpCodeGenerator
, which represents a function that generates WrapUp code for a Kipper file.KipperEqualAssignOperator
, which represents the equal assignment operator (=
).KipperAssignOperator
, which represents all available assignment operators.KipperArithmeticAssignOperator
, which represents all available arithmetic assignment operators.KipperArg
, which represents a function argument. Alias forKipperParam
.KipperParam
, which represents a function parameter.JmpStatementType
, which represents all possible jump statement types e.g.break
andcontinue
.ASTDeclarationKind
, which is a union type of all possibleParserASTNode.kind
values for aDeclaration
AST node.ASTExpressionKind
, which is a union type of all possibleParserASTNode.kind
values for aExpression
AST node.ASTStatementKind
, which is a union type of all possibleParserASTNode.kind
values for aStatement
AST node.ASTConstantExpressionKind
, which is a union type of all possibleParserASTNode.kind
values for aConstantExpression
AST node.ParserConstantExpressionContext
, which is a union type of all possibleParserASTNode.antlrRuleCtx
values for aConstantExpression
AST node.ASTTypeSpecifierExpressionKind
, which is a union type of all possibleParserASTNode.kind
values for aTypeSpecifierExpression
AST node.ParserTypeSpecifierExpressionContext
, which is a union type of all possibleParserASTNode.antlrRuleCtx
values for aTypeSpecifierExpression
AST node.ASTUnaryExpressionKind
, which is a union type of all possibleParserASTNode.kind
values for aUnaryExpression
AST node.ParserUnaryExpressionContext
, which is a union type of all possibleParserASTNode.antlrRuleCtx
values for aUnaryExpression
AST node.ASTComparativeExpressionKind
, which is a union type of all possibleParserASTNode.kind
values for aComparativeExpression
AST node.ParserComparativeExpressionContext
, which is a union type of all possibleParserASTNode.antlrRuleCtx
values for aComparativeExpression
AST node.ConstructableASTStatementClass
, which is a union type of all possibleStatement
AST node classes.ASTLogicalExpressionKind
, which is a union type of all possibleParserASTNode.kind
values for aLogicalExpression
AST node.ParserLogicalExpressionContext
, which is a union type of all possibleParserement
AST node classes.ConstructableASTExpressionClass
, which is a union type of all possibleExpression
AST node classes.ConstructableASTDeclarationClass
, which is a union type of all possibleDeclaration
AST node classes.ConstructableASTNodeClass
, which is a union type of all possibleASTNode
AST node classes.ConstructableASTStatement
, which is a union type of all possibleStatement
AST node instances.ConstructableASTExpression
, which is a union type of all possibleExpression
AST node instances.ConstructableASTDeclaration
, which is a union type of all possibleDeclaration
AST node instances.ConstructableASTNode
, which is a union type of all possibleASTNode
AST node instances.ASTKind
, which represents a union of all AST node kind values that can be used to map a KipperParser rule context to an AST node. This is the type representing all values fromParserASTMapping
.ConstructableASTKind
, which is the same asASTKind
, but removes any kind value that does not have a corresponding AST node class.KipperReferenceableFunction
, which represents a function that can be referenced by aFunctionCallExpression
.ASTNodeParserContext
, which represents a union of all possibleParserASTNode.antlrRuleCtx
values implemented in theKipperParser
that have a corresponding AST node class.
- New fields/properties:
CompileConfig.recover
, which if set enables compiler error recovery.CompileConfig.abortOnFirstError
, which changes the compiler error handling behaviour and makes it abort on the first error encountered. This overwritesrecover
per default.RootASTNode.target
, which returns theKipperCompileTarget
of the program ctx the root AST node is in.RootASTNode.codeGenerator
, which returns theKipperTargetCodeGenerator
of the program ctx the root AST node is in.RootASTNode.semanticAnalyser
, which returns theKipperTargetSemanticAnalyser
of the program ctx the root AST node is in.ASTNode.typeSemantics
, which contains the type data for an ASTNode that was evaluated during type checking.ScopeFunctionDeclaration.typeData
, which returns the type data of the function AST node.ScopeVariableDeclaration.typeData
, which returns the type data of the variable AST node.ScopeVariableDeclaration.valueWasUpdated
, which returns true if the variable was updated after its initial declaration.ScopeDeclaration.isDefined
, which is an abstract field that returns whether the scope declaration was defined during its declaration.ScopeDeclaration.hasValue
, which is an abstract field that returns whether the scope declaration has a value set.FunctionDeclaration.innerScope
, which returns the inner scope of the function declaration. This can be used before semantic analysis, though will return undefined if it encounters any error.TracebackMetadata.errorNode
, which contains the error node that caused the error.CompilableASTNode.errors
andRootASTNode.errors
, which returns all errors caused by this node and or its children.KipperProgramContext.hasFailed
,CompilableASTNode.hasFailed
,RootASTNode.hasFailed
, which returns true if the node or any of its children have failed to be processed during semantic analysis or type checking.Scope.parent
, which returns the parent scope of the scope. This is used to recursively evaluate references in all parent scopes.ParserASTNode.kind
, which returns the kind of the parser AST node. This returns theKipperParser
rule number, as defined byKipperParser.RULE_*
.StatementASTNodeFactory.statementMatchTable
, which returns the match table for the statement AST node factory.ExpressionASTNodeFactory.expressionMatchTable
, which returns the match table for the expression AST node factory.DeclarationASTNodeFactory.declarationMatchTable
, which returns the match table for the declaration AST node factory.CompileConfig.builtInFunctions
, which overwrites the built-in functions of the target.CompileConfig.extendBuiltInFunctions
, which adds new built-in functions to the target.CompileConfig.builtInVariables
, which overwrites the built-in variables of the target.CompileConfig.extendBuiltInVariables
, which adds new built-in variables to the target.Expression.hasSideEffects
, which returns true if the expression has side effects and as such affects the state of the program. This is primarily used for reporting warnings.
- New constants:
kipperNullType
, which represents the Kipper null type.kipperUndefinedType
, which represents the Kipper undefined type.ParserASTMapping
, which is a special mapping object used to get the AST kind number for aKipperParser
rule ctx instance.kipperRuntimeBuiltInVariables
, which contains the built-in variables of the Kipper runtime.
- Moved TypeScript target from the core package to a new monorepo package called
@kipper/target-ts
, which implements the semantic analysis and code generation for TypeScript, and provides the classKipperTypeScriptTarget
(TargetTS
available as alias), which can be used as the target in theCompileConfig
. - Updated behaviour of the Compiler semantic analysis and implemented a basic error recovery system. (#198)
- Updated behaviour of Kipper Compiler semantic analysis and separated primary semantic analysis, type checking and target-specific semantic analysis into their own processing steps. (E.g. First, all AST nodes are semantically analysed, then type checked and semantically analysed for the target language)
- Updated the built-in functions' generation behaviour, by making every built-in function be defined inside the global
variable
__kipper
and the global object propertyglobalThis.__kipper
. This means that the functions are directly bound to the JS runtime and any function definition in the generated file is placed after the initial evaluation of the global scope. - Updated the function call syntax and made the
call
keyword optional. This allows for simplified function calls, such asprint("Hello world!");
. - Default error identifier is now just
Error
instead ofKipperError
. - Migrated the internal storage of
Scope
and its implementing classes to a hashmap implementation. - Updated types of
CompilableASTNode
functionsprimarySemanticAnalysis
,primarySemanticTypeChecking
andtargetSemanticAnalysis
and made them possibly undefined if there is nothing to check. This is to improve performance and not call an async function unnecessarily. - Allowed the use of function declarations inside nested scopes (e.g. inside a function body or compound statement).
- Split grammar file
Kipper.g4
intoKipperLexer.g4
andKipperParser.g4
. - Updated factory system for
StatementASTNodeFactory
,DeclarationASTNodeFactory
andExpressionASTNodeFactory
to use a mapping table instead of a switch statement for better readability and accessibility. This also allows for easier extension of the factory system. Thecreate
function is now instance-based (not static anymore) as well. - Constructor in
KipperParseStream
to allow either anCharPointCharStream
or astring
as input, but not allow a mismatch content between the two. - Cleaned up structure in
KipperFileASTGenerator
(previouslyKipperFileListener
) and removed unnecessary code. - Renamed:
EvaluatedCompileOptions
toEvaluatedCompileConfig
.UnableToDetermineMetadataError
toUndefinedSemanticsError
.ReadOnlyAssignmentTypeError
toReadOnlyWriteTypeError
.InvalidAssignmentTypeError
toAssignmentTypeError
.InvalidArgumentTypeError
toArgumentTypeError
.InvalidArithmeticOperationTypeError
toArithmeticOperationTypeError
.InvalidReturnTypeError
toFunctionReturnTypeError
.UndefinedIdentifierError
toUndefinedReferenceError
.UnknownIdentifierError
toUnknownReferenceError
.FunctionDeclarationSemantics.args
toparams
.KipperTypeChecker.argumentTypesMatch
tovalidArgumentValue
.ListPrimaryExpression
toArrayLiteralPrimaryExpression
.FunctionCallPostfixExpression
toFunctionCallExpression
.antlrDefinitionCtxType
toParserDeclarationCtx
.antlrExpressionCtxType
toParserExpressionCtx
.antlrStatementCtxType
toParserStatementCtx
.ParserExpressionCtx
toParserExpressionContext
.ParserStatementCtx
toParserStatementContext
.ParserDeclarationCtx
toParserDeclarationContext
.KipperFileListener
toKipperFileASTGenerator
.KipperProgramContext.addError
toreportError
.kipperRuntimeBuiltIns
tokipperRuntimeBuiltInFunctions
.kipperInternalBuiltIns
tokipperInternalBuiltInFunctions
.
- Moved:
- Function
KipperSemanticsAsserter.getReference
to classKipperSemanticChecker
. - Function
KipperSemanticsAsserter.getExistingReference
to classKipperSemanticChecker
. - Function
indentLines
to filetools.ts
of@kipper/target-js
. - Function
CompilableASTNode.semanticAnalysis
toAnalysableASTNode
. - Function
CompilableASTNode.semanticTypeChecking
toAnalysableASTNode
. - Function
CompilableASTNode.wrapUpSemanticAnalysis
toAnalysableASTNode
. - Function
CompilableASTNode.recursivelyCheckForWarnings
toAnalysableASTNode
. - Function
CompilableASTNode.recursivelyCheckForWarnings
toAnalysableASTNode
. - Abstract Function
CompilableASTNode.primarySemanticAnalysis
toAnalysableASTNode
. - Abstract Function
CompilableASTNode.primarySemanticTypeChecking
toAnalysableASTNode
. - Abstract Function
CompilableASTNode.checkForWarnings
toAnalysableASTNode
. - Field
CompilableASTNode.programCtx
toAnalysableASTNode
. - Field
CompilableASTNode.compileConfig
toAnalysableASTNode
. - Field
CompilableASTNode.errors
toAnalysableASTNode
. - Field
CompilableASTNode.addError
toAnalysableASTNode
. - Field
CompilableASTNode.hasFailed
toAnalysableASTNode
.
- Function
- Multiple reference and declaration bugs, which resulted in invalid handling of declarations and assignments to undefined variables and allowed the referencing of variables that were not defined or had no value set.
- Grammar bug which didn't allow the representation of empty lists (e.g.
[]
). - Multiple reference and declaration bugs, which resulted in invalid handling of declarations and assignments to undefined variables and allowed the referencing of variables that were not defined or had no value set.
- Grammar bug which didn't allow the representation of empty lists (e.g.
[]
). - A bug where using a
KipperParseStream
multiple times would result in theCodePointCharStream
being empty. - Grammar bug not allowing an empty statement (
;
) in a compound statement.
- Kipper CLI command
update
, as it was not needed since there are no plans to deploy S3 distributions of Kipper. KipperError.isWarning
, which has been replaced by the new classKipperWarning
.KipperCharType
(char
) and its grammar implementation, meaning all string types from now on will only be of typestr
. This also means that the single-quote character'
can from now also be used for string literals and f-strings with the same behaviour as the regular double-quoted character"
.KipperReturnType
andkipperReturnTypes
, as they are always identical to theKipperType
andkipperTypes
respectively.FunctionReturnTypeError
, as it is obsolete since all return types are valid.- The following fields:
Scope.functions
(replaced by hash-map implementation ofScope
).Scope.variables
(replaced by hash-map implementation ofScope
).Scope.getVariable
(replaced by hash-map implementation ofScope
).Scope.getFunction
(replaced by hash-map implementation ofScope
).KipperError.antlrCtx
, as it was replaced byTracebackMetadata.errorNode
.KipperTypeChecker.validReturnType
, as it is obsolete due to the absence ofKipperReturnType
.
- The following functions:
KipperFileASTGenerator.handleIncomingDeclarationCtx
(removed in clean-up).KipperFileASTGenerator.handleIncomingStatementCtx
(removed in clean-up).KipperFileASTGenerator.handleExitingStatementOrDefinitionCtx
(removed in clean-up).KipperFileASTGenerator.handleIncomingExpressionCtx
(removed in clean-up).KipperFileASTGenerator.handleExitingExpressionCtx
(removed in clean-up).KipperProgramConext.builtInReferences
(replaced bybuiltInFunctionReferences
andbuiltInVariableReferences
).KipperProgramConext.registerBuiltIns
(replaced byregisterBuiltInFunctions
andregisterBuiltInVariables
).CompileConfig.builtIns
(replaced bybuiltInFunctions
andbuiltInVariables
).CompileConfig.extendBuiltIns
(replaced byextendBuiltInFunctions
andextendBuiltInVariables
).
- Parser rule
arraySpecifierExpression
(ArraySpecifierExpression
), which was made obsolete with the addition ofbracketNotationMemberAccessExpression
(BracketNotationMemberAccessExpression
).
0.9.2 - 2022-07-23
- Fixed traceback bug for re-declarations inside compound statements generating an invalid error message and traceback. (#240)
- Updated Kipper compiler error message.
0.9.1 - 2022-06-29
- Fixed invalid traceback underline formatting for Kipper errors.
- Updated error messages in multiple Kipper errors.
0.9.0 - 2022-06-26
- Entry point file for the root package
kipper
, which exports@kipper/core
allowing thekipper
package to be used in projects. - Syntax support and code generation for if, else-if and else statements (#182).
- Code generation of expression lists (e.g. expression statements containing multiple child expressions) (#173).
- Code generation for tangled expressions. (#203)
- Comparative and relational expressions, which allow for logical operations and comparisons on expressions. List of all
supported operators, which can be used between two expressions.
!=
(Not Equal Operator)==
(Equal Operator)>
(Greater than Operator)>=
(Greater or equal to Operator)<
(Less than Operator)<=
(Less or equal to Operator)
- Logical expressions, which allow for the chaining and combination of expressions and conditions. List of all available
supported operators, which can be used between two expressions/conditions:
&&
(Logical And Operator)||
(Logical Or Operator)
- Operator modified expressions, which allow for the modification of an expression using a specific operator. List
of all supported operators:
!
(Logical NOT Operator)+
(Plus Operator)-
(Minus Operator)
- Partial support for compiler warnings by allowing
KipperError
instances to be warnings ifisWarning
is set to true and implementing AST-based checks for warnings using the new functionCompilableASTNode.checkForWarnings()
. (#199) - New flag
-w/--warnings
in the commandscompile
,run
andanalyse
, which enables logger warnings. (#199) - Support for hex, binary and octal numbers. (Only minor changes, as previously the syntax for binary, octal and hex numbers was already added.) (#184)
- New errors:
InvalidRelationalComparisonTypeError
, which is thrown whenever a relational comparison is used with types that are not comparable.InvalidUnaryExpressionTypeError
, which is thrown whenever a unary expression has an operand with an invalid type.
- New classes:
IfStatement
, which represents if, if-else and else statements. Chained if, else-if and else statements are structured like a tree, where the top if statement represents the root and each following if statement is a section/branch of the tree.TypeSpecifierExpression
, which is an abstract class used to provide the commonality between the different type specifier expressions.ComparativeExpression
, which is an abstract class used to provide the commonality between the different comparative expressions.LogicalExpression
, which is an abstract class used to provide the commonality between the different logical expressions.UnaryExpression
, which is an abstract class used to provide the commonality between the different unary expressions.SwitchStatement
, which represents a switch selection statement.DefinitionASTNodeFactory
, which is a factory that creates a definition instance based on aantlrRuleCtx
.ExpressionASTNodeFactory
, which is a factory that creates an expression instance based on aantlrRuleCtx
.StatementASTNodeFactory
, which is a factory that creates a statement instance based on aantlrRuleCtx
.
- New types:
KipperUnaryOperator
KipperLogicalAndOperator
KipperLogicalOrOperator
KipperLogicalOperator
KipperEqualityOperator
KipperRelationalOperator
KipperComparativeOperator
KipperUnaryModifierOperator
KipperIncrementOrDecrementOperator
KipperNegateOperator
KipperSignOperator
- New constants:
kipperUnaryOperators
kipperLogicalAndOperator
kipperLogicalOrOperator
kipperLogicalOperator
kipperEqualityOperators
kipperRelationalOperators
kipperComparativeOperators
kipperIncrementOrDecrementOperators
kipperNegateOperators
kipperSignOperators
- New interfaces:
IfStatementSemantics
, which contains the semantic data of an if-statement.ComparativeExpressionSemantics
, which defines the semantic data of a comparative expression.LogicalExpressionSemantics
, which defines the semantics of a logical expression.UnaryExpressionSemantics
, which defines the base semantics for every unary expression.TracebackMetadata
, which defines the required data for a full traceback in aKipperError
.
- New functions:
CompilableASTNode.checkForWarnings()
, which checks for warnings in an AST Node.KipperTypeChecker.validRelationalExpression()
, which ensures aRelationalExpression
is semantically valid.KipperTypeChecker.validUnaryExpression()
, which ensures aUnaryExpression
is semantically valid.KipperProgramContext.addWarning()
, which adds a warning to the program context.KipperLogger.reportWarning()
, which reports a warning with its traceback to the consoles.
- New fields/properties:
CompileConfig.warnings
, which if set to true enables warnings and stores them inKipperCompileResult.warnings
.EvaluatedCompileOptions.warnings
, which if set to true enables warnings and stores them inKipperCompileResult.warnings
.KipperCompileResult.warnings
, which contains a list of all warnings that were found during the compilation of a program.KipperError.isWarning
, which if true defines the error as non-fatal warning that does not prevent the compilation from continuing.KipperProgramContext.warnings
, which contains all warnings that have been found in the program.KipperLogger.reportWarnings
, which if set to true will report warnings to the console.KipperProgramContext.reportWarnings
, which if set to true will run warning checks on the AST nodes of the program.
- Moved
KipperSemanticChecker.arithmeticExpressionValid()
toKipperTypeChecker
and renamed it tovalidArithmeticExpression()
. - Renamed Antlr4 rule
singleTypeSpecifier
toidentifierTypeSpecifier
and its associated class toIdentifierTypeSpecifierExpression
. - Renamed:
SingleTypeSpecifierExpression
toIdentifierTypeSpecifierExpression
.ParserASTNode.getTokenChildren()
togetAntlrRuleChildren()
.Scope.localVariables
tovariables
.Scope.localFunctions
tofunctions
.
- Updated logging messages and shortened them to be more concise.
- Deprecated and replaced functions:
getDefinitionInstance
, which was replaced withDefinitionASTNodeFactory
.getExpressionInstance
, which was replaced withExpressionASTNodeFactory
.getStatementInstance
, which was replaced withStatementASTNodeFactory
.
0.8.3 - 2022-06-18
- New errors:
ReadOnlyAssignmentTypeError
, which is thrown whenever a read-only (constant) variable is being assigned to.InvalidAssignmentTypeError
, which is thrown whenever an assignment has mismatching types that are not compatible.UndefinedConstantError
, which is thrown whenever a constant declaration is not defined. (Constants may not be undefined).
- Fixed const assignment bug #188, which allowed assignments to read-only (constant) variables.
- Fixed invalid identifier translation of built-in references in the TypeScript target.
- Renamed:
KipperProgramContext.registerGlobals()
toregisterBuiltIns
.InvalidConversionError
toInvalidConversionTypeError
InvalidArithmeticOperationError
toInvalidArithmeticOperationTypeError
- Set display error name of
InvalidArithmeticOperationTypeError
toTypeError
.
0.8.2 - 2022-06-14
- Handling of integer constants and cleaned up the lexer rules in Kipper.g4.
- Updated error message of
InvalidAmountOfArgumentsError
. - Updated and improved speed of space handling by optimising parser rules and removing manual spaces in rules.
- Integer and float suffixes from the lexer rules in Kipper.g4, as they are meaningless in Kipper.
0.8.1 - 2022-06-09
- Replaced outdated
NotImplemented
errors fromKipperFileListener.ts
withKipperNotImplementedError
errors, which are now thrown inside theprimarySemanticAnalysis()
functions of the affected statements. - Updated and simplified logging messages.
- Fixed grammar issue in
Kipper.g4
, which resulted in spaces being syntactically invalid in an empty function argument list, e.g.def func( ) -> void;
was invalid before.
- Unused grammar rule
nestedParenthesesBlock
.
0.8.0 - 2022-06-07
- Implemented type conversion expressions, which allow for the conversion of a value to another type.
(#133) The following conversions are supported:
str
asnum
num
asstr
bool
asstr
bool
asnum
- Boolean constant expressions
true
andfalse
, which automatically evaluate to the typebool
and can be used in expressions. (true
andfalse
are now reserved identifiers, which can never be overwritten and any attempts to do so will be blocked by the parser). This also includes a new expression classBoolPrimaryExpression
, a new target-specific semantics functionKipperTargetSemanticAnalyser.boolPrimaryExpression
and target-specific translation functionKipperTargetCodeGenerator.boolPrimaryExpression
. (#134) - Implemented reserved identifier checking, which ensures that no declarations overwrite/interfere with an internal identifier or reserved identifier/keyword. (#153)
- Implemented tree-shaking for internal and built-in functions using the new class
KipperOptimiser
, which removes any function definitions that are not used (#159). - New field
KipperCompileTarget.builtInGenerator
, which will store the built-in generator for each target. - New classes and interfaces:
KipperTargetBuiltInGenerator
, which updates the behaviour for generating built-in functions. This function should also allow the use of built-in variables in the future and also provide a basis for dynamic dependency generation for the Kipper built-ins. This means that targets can now specify themselves how the built-in should be generated and can handle all type conversions, internal prefixes, name mangling etc. themselves.identifierTypeSpecifierExpression
, which represents a single constant type identifier, such asstr
.GenericTypeSpecifierExpression
, which represents a generic type constant, such astype<T>
. (Functionality not implemented yet! Planned for v0.12)TypeofTypeSpecifierExpression
, which represents a dynamically evaluated type, such astypeof("string")
. (Functionality not implemented yet! Planned for v0.11)InternalFunction
, which represents an internal function for Kipper, which provides specific functionality for keywords and other internal logic.KipperSemanticErrorHandler
, which implements a default abstract error handler for semantic errors. This is used byKipperTargetSemanticAnalyser
andKipperAsserter
.KipperOptimiser
, which handles code optimisation for a Kipper program.
- New functions:
KipperSemanticChecker.validConversion()
, which checks whether a type conversion is valid and implemented by Kipper.KipperOptimiser.optimise()
, which performs optimisation on an abstract syntax tree.KipperProgramContext.getBuiltInFunction()
, which searches for a built-in function based on a passed identifier.KipperProgramContext.optimise()
, which performs code optimisations for the local abstract syntax tree.
- New errors:
InvalidConversionError
, which is thrown when an invalid or unimplemented conversion is performed in a Kipper program.ReservedIdentifierOverwriteError
, which is thrown whenever a declaration identifier overwrites/interferes with an internal function or reserved keyword/identifier.
- New types and constants:
- Kipper meta type
type
, which represents the type of a Kipper type. kipperSupportedConversions
, which is an array containing multiple tuples representing allowed conversions in Kipper.
- Kipper meta type
- New
CompileConfig
optionoptimisationOptions
, which contains the configuration for theKipperOptimiser
. - Added new flags
-b/--[no-]optimise-builtins
and-i/--[no-]optimise-internals
to the@kipper/cli
for enabling internal and built-in functions optimisation.
- Updated error traceback generation algorithm to be more concise and useful. The algorithm will try from now on to mark the origin of the error in the source line, instead of only returning the characters causing the error.
- Updated folder structure of built-in targets, by moving all target-related files to
kipper/core/src/targets
. This should from now on be the folder, where all the targets that are natively supported by Kipper should be located. - Moved all typescript-related target files to
kipper/core/src/targets/typescript
and split up the classes into their own files. - Updated built-in code generation behaviour in
KipperProgramContext.generateRequirements()
. This function generates the built-ins for a program using itsKipperTargetBuiltInGenerator
, which is specified in theKipperCompileTarget
. - Fixed bug in
@kipper/cli
which occurred when reading files causing line endings to be internally removed. This resulted in CLI errors sometimes displaying an entire Kipper file as a single line of code, instead of displaying the original code line alone. - Renamed:
builtIns
tokipperRuntimeBuiltIns
.semantic-analyser.ts
totarget-semantic-analyser.ts
.ParserASTNode.ensureTokenChildrenExist()
togetTokenChildren()
.ParserASTNode.ensureSemanticDataExists()
togetSemanticData()
.KipperError.setMetadata()
toKipperError.setTracebackData()
.KipperAsserter
toKipperSemanticsAsserter
.TargetTokenCodeGenerator
toTargetASTNodeCodeGenerator
.TargetTokenSemanticAnalyser
toTargetASTNodeSemanticAnalyser
.CompilerEvaluatedOptions
toEvaluatedCompileOptions
.KipperProgramContext.processedParseTree
toabstractSyntaxTree
.KipperProgramContext.builtInGlobals
tobuiltIns
.CompileConfig.globals
tobuiltIns
.CompileConfig.extendGlobals
toextendBuiltIns
.
- Optimised and simplified Kipper code generation in
KipperCompileResult.write()
. - Updated
@kipper/core
code base structure:/parser/
now contains these new files:ast-node.test.ts
- AST Node (Previously parse-token.ts)root-ast-node.test.ts
- Root AST Node (Extracted from compilable-ast-node.test.ts)compilable-ast-node.test.ts
- Compilable AST Node (Previously compilable-parse-token.ts)
/semantics/language/
which contains the language specific AST Node classes that implement the semantics for the expressions, definitions and statements in Kipper./semantics/processor/
which is the module containing the Semantic analyser and Type checker.
- Updated local and global scope handling by introducing three new classes:
Scope
,GlobalScope
andLocalScope
. These classes now handle local variables and functions and implement a standard interface for handling declarations and definitions. - Updated
@kipper/cli
flag names from camelCase to dash-case.
- Module
kipper/core/compiler/lib
, as the built-ins shall from now on be handled by each individual target instead of the whole Kipper package to allow a unique specific implementation per target. - Deprecated errors and functions:
UnknownFunctionIdentifierError
UnknownVariableIdentifierError
KipperSemanticChecker.functionIsDefined
KipperSemanticChecker.variableIsDefined
BuiltInFunction.handler
as the core compiler will not handle code generation of Kipper built-ins (like for exampleprint
) anymore.- Support for multi strings seperated by a whitespace (e.g.
"1" "2"
is counted as a single string"12"
). This may be added back later, but for now it will be removed from the Kipper language. - Error
InvalidOverwriteError
, as all errors it represented are now subclasses ofIdentifierError
. - Unneeded functions from
KipperProgramContext
, as they were replaced by the new scope handling classes:getGlobalFunction()
getGlobalIdentifier()
getGlobalVariable()
addGlobalVariable()
- Unneeded function
determineScope()
, as the scope handling was moved toCompilableASTNode.scope
.
0.7.0 - 2022-05-22
- Implemented code generation for declarations, definitions and variable assignments (#26).
- Implemented semantic analysis for
AssignmentExpression
andVariableDeclaration
. - Implemented support for identifiers references, which means variables can now be used in the following contexts:
- As a function call argument:
call print(identifier)
- As a value in an arithmetic expression:
identifier + identifier
oridentifier + 5
- As a function call argument:
- Implemented CLI flag
-s/--stringCode
, which can be used as a replacement for the argumentfile
. (#100). This flag is available forkipper analyse
,kipper compile
andkipper run
) - Implemented single char flags for the CLI (#109).
- Additional metadata and stack info when non-compiler errors are thrown during runtime in the CLI.
- New fields:
VariableDeclarationSemantics.value
, which represents the expression that was assigned in the definition. This field isundefined
ifVariableDeclarationSemantics.isDefined
isfalse
.
- New functions:
CompileAssert.validAssignment()
, which asserts that an assignment expression is valid.abstract CompilableASTNode.semanticTypeChecking()
, which must be implemented by every child and should serve as a separate semantic type checking step outside ofprimarySemanticAnalysis()
.
- New classes:
KipperAsserter
, which is an abstract base class that represents a class that can be used to assert certain truths and handle/throw compile errors.KipperTypeChecker
andKipperSemanticChecker
, which perform specialised semantic checking and verify logical integrity and cohesion. These two classes replaceCompileAssert
.
- New errors:
InvalidAssignmentError
, which is thrown when an invalid assignment is used.KipperInvalidInputError
, which is thrown when passing invalid input to the Kipper cli.
- Optimised Kipper parsing and lexing process by updating the parsing behaviour in Kipper.g4. Kipper should handle standard expressions a lot faster from no on.
- Fixed bug #104, which caused an invalid evaluation of the return type of string additive expressions causing invalid type errors when used with other expressions.
- Fixed CLI issues with unrecognisable non-printable unicode characters, which caused errors with the Antlr4 Parser and
Lexer, when reading files using the
utf16le
encoding. - Fixed NULL character issue #114 when writing TypeScript code onto
files using the
utf16le
encoding. From now on a buffer will be created using the proper encoding (also forascii
andutf8
) that should be properly writable to a file. - Fixed incomplete translation bug #118 of chained arithmetic
expressions with the same operator (
N + N + N
) resulting in incomplete TypeScript code. - Fixed bug #111, which caused an invalid evaluation of the return type of string expressions.
- Updated logger messages.
- Updated
compiler
folder structure of the core package:compiler/parser
from now on contains everything parser and lexer-related.compiler/parser/antlr
from now on contains the Antlr4 generated parser and lexer files.compiler/semantics
from now on contains everything semantics related, such as the file listener, the Kipper tokens, logical constants etc.compiler/translation
from now on contains the classes and tools used for translating Kipper code into another language.compiler/targets
from now on contains the existing targets for Kipper, such astypescript
.compiler/lib
from now on contains the standard library and built-ins for Kipper.compiler/lib/import
from now on contains the default importable libraries for Kipper.
- Renamed:
- Error
InvalidTypeError
toTypeError
. - Function
KipperProgramContext.addNewGlobalScopeEntry
toaddGlobalVariable()
. - Function
CompoundStatement.addNewLocalVariable
toaddLocalVariable()
.
- Error
- Unnecessary traceback when encountering Kipper runtime errors as explained in #110.
- Option to use unary expressions for the left-hand side of an assignment expression in Kipper.g4. (Only identifiers may be used.)
- Option to redeclare variables. From on a variable declaration can only be done once and afterwards the variable may only be overwritten or modified, but not re-declared. This should help make Kipper have a similar behaviour to TypeScript.
0.6.1 - 2022-05-17
@types/node
as a dependency for@kipper/cli
.
- Updated locale dependency requirements for kipper packages to
~
(Accepting patches, but not new features). E.g.@kipper/cli
requires"@kipper/core": "~0.6"
0.6.0 - 2022-05-16
- Implemented TypeScript translation for constant numeric values (
NumberPrimaryExpression
). - Implemented TypeScript translation for arithmetic expressions:
MultiplicativeExpression
andAdditiveExpression
. - New base interface
ExpressionSemantics
, which is the base for all expression semantics. - New interface
ArithmeticExpressionSemantics
which is used as a parent forMultiplicativeExpressionSemantics
andAdditiveExpressionSemantics
. - Field
args
inFunctionCallPostfixExpressionSemantics
, which contains theExpression
instances representing the arguments of a function call. - New functions:
getTokenIntervalSource()
, which fetches the source code for an interval of twoToken
instances.getParseTreeSource()
, which fetches the source code for a parse tree.CompilableASTNode.ensureTokenChildrenExist()
, which throws anUnableToDetermineMetadataError
error in case that the children tokens are undefined.KipperProgramContext.semanticAnalysis()
(which allows for semantic analysis without compiling)KipperProgramContext.translate()
, which translates a processed parse tree.CompileAssert.getExistingVariable()
andCompileAssert.getExistingReference()
for fetching reference variables based on an identifier.CompoundStatement.getLocalVariable()
andCompoundStatement.getVariableRecursively()
for fetching a variable based on an identifier inside aCompoundStatement
/KipperScope
.
- New types:
KipperReturnType
, which represents valid types that may be returned from a function.KipperPrimitiveType
, which represents primitive types in Kipper.KipperMultiplicativeOperator
, which represents multiplicative operators (*
,/
,**
and%
).KipperAdditiveOperator
, which represents additive operators (+
and-
).KipperPlusOperator
, which represents the Kipper plus operator.KipperMinusOperator
, which represents the Kipper minus operator.KipperStrLikeTypes
, which represents string-like Kipper types, likechar
andstr
.
- New errors:
UndefinedSemanticsError
, which specifically is thrown whenever the semantics of a token are undefined.UndefinedIdentifierError
, which is thrown when an identifier is referenced that does not exist.ArgumentError
, which is thrown whenever there is an error related to invalid arguments inside a function call.InvalidReturnTypeError
, which is thrown whenever an invalid type is set as return type of a function.InvalidAmountOfArgumentsError
, which is thrown whenever an invalid amount of arguments is passed to a function.InvalidArithmeticOperationError
, which is thrown whenever an invalid arithmetic operation is performed.KipperNotImplementedError
, which is thrown when a feature is used that is not yet implemented in Kipper.
- New constants:
defaultWebBuiltIns
anddefaultNodeBuiltIns
, which provide the default built-in functions for Kipper. Kipper will attempt from now on to detect whether the environment is a browser and usedefaultWebBuiltIns
in that case and otherwise default todefaultNodeBuiltIns
.kipperStorageTypes
, which represents all valid storage types in Kipper.kipperMultiplicativeOperators
, which represents all valid multiplicative operators in Kipper.kipperAdditiveOperators
, which represents all valid additive operators in Kipper.kipperArithmeticOperators
, which combines bothkipperAdditiveOperators
andkipperMultiplicativeOperators
.kipperVoidType
, which represents the Kipper void type.kipperFuncType
, which represents the Kipper func type.kipperBoolType
, which represents the Kipper bool type.kipperNumType
, which represents the Kipper num type.kipperCharType
, which represents the Kipper char type.kipperStrType
, which represents the Kipper str type.kipperPlusOperator
, which represents the Kipper plus operator.kipperMinusOperator
, which represents the Kipper minus operator.kipperStrLikeTypes
, which represents string-like Kipper types, likechar
andstr
.
- Renamed:
getTokenSource
togetParseRuleSource
, and replaced the original function withgetTokenSource
that only fetches the code for a singleToken
instance.CompilableASTNode.antlrCtx
toantlrRuleCtx
.functionIdentifierNotUsed
tofunctionIdentifierNotDeclared
.variableIdentifierNotUsed
tovariableIdentifierNotDeclared
.- Field
name
toidentifier
in interfaceBuiltInFunctionArgument
.
- Deprecated the following items (Should be removed in
0.8.0
):variableIsDefined
functionIsDefined
UnknownVariableIdentifierError
UnknownFunctionIdentifierError
- Invalid expression class
ArgumentExpressionListExpression
and its abstract translation function inKipperTargetCodeGenerator
. - Unneeded function
RootFileParseToken.compileCtx
.
0.5.0 - 2022-05-11
- New field
target
inCompileConfig
, which defines the compilation target for a Kipper program. - New field and constructor argument
KipperProgramContext.target
, which defines the compilation target for the program. - New type
TargetTokenSemanticAnalyser
, which represents a function type that semantically analyses aCompilableASTNode
. - New type
TargetTokenCodeGenerator
, which represents a function type that semantically analyses aCompilableASTNode
. - Target-specific code generator
KipperTargetCodeGenerator
, which defines the functions that convert the Kipper code into a specific target language. - Target-specific semantic analyser class
KipperTargetSemanticAnalyser
, which can define additional semantic analysis logic for a compilation target. - Class
KipperCompileTarget
which defines the functions and classes for how to handle the translation to a specific target. - Class
TypeScriptTarget
, which defines the default target for Kipper. - Abstract fields
targetCodeGenerator
andtargetSemanticAnalysis
, which must be defined in child classes of abstract base classCompilableASTNode
. - New getters
target
,codeGenerator
andsemanticAnalyser
in classCompilableASTNode
. - New protected functions
primarySemanticAnalysis
andtargetSemanticAnalysis
, which are split to separate the core/primary semantic analysis and the target specific semantic analysis. - New types
KipperVoidType
,KipperNumType
,KipperStrType
,KipperCharType
,KipperBoolType
andKipperListType
, which represent Kipper available types in the Kipper language. core/primary semantic analysis and the target specific semantic analysis. - Assert function
CompileAssert.getExistingFunction()
for fetching a function and throwing an error if it does not exist. - New CLI commands:
version
, which returns the currently installed Kipper version.update
, which updates the CLI if a new version is available.
- New CLI plugins:
- Plugin and manual command
update
, which updates the CLI if a new release is available. - Plugin
warn-if-update-available
, which will display a warning when the CLI is used that a new version can be installed.
- Plugin and manual command
- Deprecated
@kipper/base
as it is now replaced with@kipper/core
. - Fixed
@kipper/cli
bug causing logging messages to only contain "anonymous-script". - Extracted the content of the
RootFileParseToken.compileCtx
function and added new two functionsRootFileParseToken.semanticAnalysis()
, which semantically analysis the code for basic semantics and target-specific semantics, andRootFileParseToken.translate()
, which translates the code into the specific target. - Made
CompilableASTNode.semanticAnalysis()
andCompilableASTNode.translateCtxAndChildren()
non-abstract and implemented basic processing algorithm to run the code fromCompilableASTNode.targetCodeGenerator
andCompilableASTNode.targetSemanticAnalysis
. - Changed semantic definitions for
CompilableASTNode
children classes and created for each child class a representing semantics class defining the metadata for the token. - Renamed error
UnknownFunctionIdentifier
toUnknownFunctionIdentifierError
. - Renamed function
CompileAssert.assertTypeExists
totypeExists
.
- File
CHANGELOG.md
from@kipper/cli
and@kipper/core
, as it is now only shipped withkipper
.
0.4.0 - 2022-05-03
- New function
KipperLogger.reportError()
for reporting and logging errors. - New function
KipperAntlrErrorListener.getSourceCode()
for fetching the source code for a syntax error. - Proper tracebacks handling for
KipperSyntaxError
(#42). - Getter fields
line
,col
,filePath
andtokenSrc
inKipperError
, which returns the metadata for the error. - Fallback option for Lexer errors, where if
offendingSymbol
isundefined
the entire line of code is set astokenSrc
(#36). - Getter field
KipperParseStream.lines
returning all lines in the source file as an array.
- Fixed missing traceback line hinting (#24).
- Fixed missing error and fatal error logs (#34).
- Renamed function
CompileAssert.error()
toCompileAssert.throwError()
and added error logging for the error passed as argument. - Renamed
KipperErrorListener
toKipperAntlrErrorListener
. - Renamed
InternalKipperError
toKipperInternalError
. - Fixed usage of default antlr4 listeners for lexer errors (#36).
- Field
KipperCompiler.errorListener
, as due to (#42) theKipperAntlrErrorListener
will have to be initialised per compilation, not per compiler instance. - Namespace
Utils
and moved its methods into the global scope of the file to allow the following import schemeimport * as Utils from "@kipper/core/utils"
, where the user can themselves define the wanted scope identifier.
0.3.0 - 2022-04-28
- Implemented handling of declarations and definitions, where definitions can only appear once. ( Reassignments are not counted as definitions!)
- Traceback handling using
KipperErorr.getTraceback()
andKipperError.setMetadata
. - New namespace
Utils
with new functiongetTokenSource()
anddetermineScope()
. - New errors
FunctionDefinitionAlreadyExistsError
andVariableDefinitionAlreadyExistsError
, which are raised if definition rules are violated. - Project version information constants in
index.ts
. - Implemented abstract classes to differentiate error groups:
InvalidOverwriteError
andIdentifierError
. KipperInternalError
, which is raised in case there is an internal error/bug.
- Renamed definition errors:
DuplicateVariableDefinitionError
toIdentifierAlreadyUsedByVariableError
DuplicateFunctionDefinitionError
toIdentifierAlreadyUsedByFunctionError
- Renamed
antlrContext
toantlrCtx
across all files. - Changed behaviour of the
assert
system:- All assertion will if possible now handled using the expression
KipperProgramContext.assert(ctx).ASSERT_FUNC()
. - Assertions should happen in the
semanticAnalysis()
step. - Registrations and updates of stack information should also happen in the
semanticAnalysis()
step to properly compile top to bottom. (For now there is no support for calling functions that are defined afterwards in the file. So a pre-declaration is required!)
- All assertion will if possible now handled using the expression
- Updated behaviour of
CompilableASTNode
to determine semantics and semantic types using generic classes. This means all semantic data is now stored using the get and setterCompilableASTNode.semanticData
.
- Method
CompilableASTNode.compileCtx()
added in0.2.0
, and split the handling of the semantic analysis and compilation into two separate stages. This means that before compilation, all children will be semantically analysed. Starting from the bottom/the simplest tokens working upwards as the tokens get more complicated. - Unneeded private tracking of
_currentScope
inKipperFileListener
, as the scope handling system has been replaced with a dynamic determination usingsemanticAnalysis()
.
0.2.1 - 2022-04-22
- Updated kipper-standalone global identifier behaviour and added support for WebWorkers.
0.2.0 - 2022-04-13
- Created new class
CompileAssert
, which is used to assert certain compiler-required truths, which, if false, trigger corresponding errors. - New errors
UnknownVariableDefinition
andUnknownFunctionDefinition
. - New getter
CompilableASTNode.tokenStream
, which returns theprogramCtx.tokenStream
instance. - Created new expression class
ArgumentExpressionList
representing an argument list inside function calls. - New function
KipperCompileResult.write()
, which creates a human-readable string from the generated source code. - Added new property and constructor parameter
logLevel
, which defines which messages should be logged. (Only messages with equal or higher importance will be logged). - Added class name insertion for custom Kipper errors by setting the
name
property explicitly.
- Changed execution of most compilation functions to async.
- Replaced
DuplicateIdentifierError
withDuplicateVariableDefinitionError
andDuplicateFunctionDefinitionError
. - Renamed
NoBuiltInOverwriteError
toBuiltInOverwriteError
. - Made all
getMetadata
functions/tokens/
instance-methods, removing all required parameters. - Changed compilation result from
Array<string>
toArray<Array<string>>
, where each nested array represents a line combined of string tokens. - Set explicit children type for expressions and statements, instead of letting them inherit the children type from
CompilableASTNode
. - Set return type of
compileCtx
toArray<string>
in children classes ofExpression
.- Changed visibility of
CompilableASTNode.semanticAnalysis()
andCompilableASTNode.translateCtxAndChildren()
toprotected
, as they will be replaced and tied together usingCompilableASTNode.compileCtx()
.
- Changed visibility of
- Replaced compilation in
RootParseToken.translateCtxAndChildren
withRootParseToken.compileCtx()
. - Changed values of
LogLevel
to numeric values, which can be translated into strings usinggetLogLevelString()
.
- Functions
RootParseToken.semanticAnalysis()
andRootParseToken.translateCtxAndChildren
0.1.2 - 2022-04-06
- Implemented simple scope logic by adding the
scope
property to allStatement
classes and creating a tracking variable called_currentScope
inKipperFileListener
, which will be updated while processing the parse tree. - Added variable metadata handling in
VariableDeclaration
. The class will now on construction determine its identifier, storage type, value type and state (whether it was defined yet) using its antlr4 context instance. - Added errors
BuiltInOverwriteError
,UnableToDetermineMetadataError
andUnknownTypeError
. - Added new abstract base class
ScopeDeclaration
, which is the parent class for the already existingScopeDeclaration
and the addedScopeFunctionDeclaration
. - Implemented
KipperProgramContext.globalScope
, which contains all global variables and function definitions. - Implemented support for function definitions that will be from now on automatically registered globally.
- Renamed class
ScopeDeclaration
toScopeDeclaration
and updated its constructor to require a token (VariableDeclaration
instance), which will automatically set the properties (identifier, storage type, value type, scope and state). - Rearranged constructor arguments of
KipperParseStream
tostringContent, name, charStream
, and setname
to default to"anonymous-script"
. - Updated
CompoundStatement
children behaviour, by adding a new arraylocalScope
, which will store the metadata for all variables exclusively available in that compound statement.
0.1.1 - 2022-04-01
- Added missing dependency
tslib
0.1.0 - 2022-04-01
KipperFileListener.itemBuffer
, which will contain the generated TypeScript code-lines, that were generated in the walking step.- Basic
KipperFileContext
, which will serve as the base class, where the compilation data is stored. - General namespace import of
kipper
inindex.ts
, which allows the usage of the entire library. KipperFileContext.translate()
, which walks through the listener and returns the generated code. The generated code will be cached insideKipperFileContext.typescriptCode
to allow reusing code instead of unnecessarily generating code again.LogLevel.UNKNOWN
as the default log level forLogLevel
.KipperLogger.levels
as a static variable to access the enumLogLevel
.- New abstract base class
CompilableASTNode
, which will represent the major parse tokens inside a kipper program. The token class has the additional functionality of wrapping an entire antlr4 statement, expression or block, and being able to semantically analyse it usingsemanticAnalysis()
and translate it to TypeScript usingcompileCtx()
. - Properties
parser
,lexer
,errorHandler
andtokenStream
inside the classKipperFileContext
. - File
builtIns.ts
, which defines the behaviour on how to define built-in items inside a kipper program. This primarily includes global functions, which can be represented using the interfaceBuiltInFunction
. (In work!) - Implemented
**
(Power-to) as a valid arithmetic expression. - Implemented
RuntimeCompileConfig
andCompileConfig
, which may be passed ontoKipperCompile.compile()
to configure the compilation behaviour. - Implemented new module
/compiler/tokens
, which contains the parse token implementations. - Implemented basic global function
print
that will be available inside a Kipper program per default (unless forcibly changed). - New Class
ScopeDeclaration
representing a declaration/entry inside a scope. This is used primarily insideKipperProgramContext
, which uses it to keep track of global definitions and alsoCompoundStatement
s, which may have children definitions. - Type Implementation with two new type aliases:
KipperStorageType
andKipperType
.
- Made return of
KipperCompiler.parse()
toKipperFileContext
, which wraps the generated parse tree. - Behaviour of
KipperCompileResult
, which will now store theprogramCtx: KipperFileContext
andresult: string[]
of a compilation. - Fixed bug in
KipperErrorListener
, which resulted in errors being not properly raised. The function is now a template, where<T>
represents the offending token.<T>
will also be passed ontoKipperSyntaxError<T>
. - Changed type of
LogLevel
, which now returns string-representations of the log level. - Fixed
initializer
rule in Kipper.g4 and removed invalid designator rules. - Updated all expressions in
Kipper.g4
to contain proper labelled sub-rules, which clearly state if the expression is used or if it's a pass on and an expression with higher importance is used (child of that expression). - Renamed
KipperFileContext
toKipperProgramContext
, which will now handle the entire compilation and store its meta-data.
- Unneeded namespace
KipperStreams
and its functions. - Unneeded variable
LogLevelNames
, as now the enumLogLevel
per default returns the names of the level. - Removed
preferLogging
options in the entire module, as errors and warnings will always be logged no matter what. This also means that errors will always be logged and thrown as a catchable error instance. - Argument
streamName
inKipperCompiler.syntaxAnalyse()
andKipperCompiler.compile()
.
0.0.5 - 2022-03-02
- Fixed invalid publish of the module on npm
0.0.4 - 2022-03-02
Broken version!
0.0.3 - 2022-03-02
- Build Option for the browser-compatible script
kipper-standalone.js
- Basic
run
command for running a compiled file or compiling and running a file. (This is still in development). - Basic
compile
command for compiling a file into it's js-counterpart with its typescript types added. - New Parse Stream class
KipperParseStream
, which implements a basic Utf-16 stream. - Support for
[]
initializers for lists in Kipper.g4. - Support for
multiItemTypeSpecifier
, which use theidentifier<T>
syntax (for lists specifically). - Support for
typeof(V)
(typeofTypeSpecifier
) syntax fortypeSpecifier
expressions. - Support for Kipper-Conversion
identifier as typeSpecifier
syntax. - Support for for-loops using the
for(INIT_EXPRESSION; CONDITION, LOOP_EXPRESSION) STATEMENT
syntax. - New Map
LogLevelNames
, which will mapLogLevel
enum values to constant strings (e.g.LogLevel.CRITICAL
->"CRITICAL"
).
- Fixed syntax bug in Kipper.g4 that caused typed arguments to not be able to passed to functions.
- Updated handling of the
KipperLogger
, which will now only use anemitHandler
, which can be defined by the user. This means the user entirely decides how to handle the logging output of the compiler, and there is no default logging anymore.
- Oclif CLI, which will be released in another package separate to this one, as this will be made to suit the usage inside a browser.
KipperParseFile
, which will be implemented in the NodeJS CLI implementation for Kipper
0.0.2 - 2021-11-23
oclif
environment with the appropriate tests/test/module
for module specific tests usingmocha
KipperErrorListener<Token>
for listening toKipperParser
andKipperLexer
errorsParserFile
for implementing the stream that may be used forKipperCompiler.parser()
- Updated file structure to separate
commands
(foroclif
) andcompiler
(for the compiler source-code)