Changelog
View the latest changes to Kipper.
View the latest changes to Kipper.
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.
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.
new
keyword expression to be able to
create new instances of classes. (#679)
this
keyword inside a class method to access the current instance of
the class. (#697)
instanceof
operator expression, which checks if an object is an instance of
a class. (#686)
matches
operator expression, which checks if an object matches an
interface. (#672)
Array<T>
type and single-type array initializers. (#499)
Func<T..., R>
type and function type initializers. (#584)
T...
, which allows multiple arguments to
be passed to a single parameter inside a generic type specifier.
NaN
, which represents the NaN
value in JavaScript
(Not a Number). (#671)
obj
type translation to TypeScript.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.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 reference
BuiltInTypeObject
, which is the base class for the compilers representation of
runtime objects
UniverseScope
, 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 the any
type.BuiltInTypeVoid
, which represents the void
type.BuiltInTypeNull
, which represents the null
type.BuiltInTypeUndefined
, which represents the undefined
type.BuiltInTypeBool
, which represents the bool
type.BuiltInTypeNum
, which represents the num
type.BuiltInTypeStr
, which represents the str
type.BuiltInTypeArray
, which represents the Array<T>
type.BuiltInTypeFunc
, which represents the Func<T..., R>
type.BuiltInTypeObj
, which represents the obj
type.ScopeTypeDeclaration
, which represents a scope type declaration.CustomType
, which is a class extending from ProcessedType
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 the this
declaration of a
class.
InstanceOfExpression
, which represents the instanceof
operator
expression.
MatchesExpression
, which represents the matches
operator expression.
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 the
instanceof
operator is used with a type other than a class.
InvalidMatchesTypeError
, which is thrown when the matches
operator is
used with a type other than an interface.
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 type Reference
in the
KipperProgramContext
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 for FunctionDeclaration
,
LambdaPrimaryExpression
and ClassMethodDeclaration
.
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.
KipperTypeChecker.validArrayExpression()
, which ensures that an array expression is
valid.
KipperTypeChecker.validInstanceofClassType()
, which ensures that an
instanceof
expression is valid for a class.
KipperTypeChecker.validMatchesInterfaceType()
, which ensures that a
matches
expression is valid for an interface.
ClassDeclaration.getThis()
, which returns the this
type of the class.
ClassScope.getThis()
, which returns the this
type of the class. This
is a simple alias for the method in the ClassDeclaration
class.
JavaScriptTargetCodeGenerator.generateInterfaceRuntimeTypeChecks()
which generates
runtime type checks for an interface.
getRuntimeType()
, which gets the corresponding runtime representation of a built-in
type.
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 extends
BuiltInTypeFunc
.
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.
KipperError
, which serves as the base for TypeError
and
IndexError
.
print
from str
to any
.
len
from str
to
str | Array<any>
. (#667)
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.analysis
to semantics
.compiler/.../expressions/arithmetic
to arithmetic-expression
.
UncheckedType
to RawType
.CheckedType
to ProcessedType
.UndefinedCustomType
to UndefinedType
.KipperProgramContext._initUniversalReferencables()
to
_initUniversalReferenceables()
.
Func
instead of the appropriate filled-up
Func<T..., R>
type. This now enables proper type checking for function
references.
run
not properly reporting internal or unexpected errors, as they were
already prettified in the internally called up command compile
.
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.
KipperProgramContext
for built-in types,
functions and variables.
Reference
as it is no longer needed and has been replaced by
KipperReferenceable
.
FunctionCallExpressionTypeSemantics.func
, which is now has been replaced by
funcOrExp
.
KipperProgramContext.setUpBuiltInsInGlobalScope()
, which is no longer needed
as the universe scope now handles all built-in types, functions and variables.
&
, |
, ^
, ~
,
<<
, >>
, >>>
). (#493)
COND ? EXP : EXP
) as a ternary operator. (#534)
do ... while ...
) iteration statements. (#271)
@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).
@kipper/cli
to automatically create a Kipper project with a
config file. (#502).
*
operator. (#478).
--dry-run
in compile
, which only compiles the program and
does not write any outputs. (#532).
void
to str
.null
to str
.undefined
to str
.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 file
factories.ts
and contains all AST factory classes and types.
kipper/core/compiler/ast/mapping
, which contains all AST mapping objects and the
ASTNodeMapper
class.
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.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.
ignoreParams
in genJSFunction()
, which, if true makes the function
signature define no parameters.
ignoreParams
in createJSFunctionSignature()
, which, if true makes the
function signature define no parameters.
ignoreParams
in genTSFunction()
, which, if true makes the function
signature define no parameters.
ignoreParams
in createTSFunctionSignature()
, which, if true makes the
function signature define no parameters.
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.
KipperError.programCtx
, which contains, if
KipperError.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.InverseMap
, which inverts a map by swapping the keys and values.KipperTargetBuiltInGenerator.voidToStr()
, for the built-in conversion from
void
to str
.
KipperTargetBuiltInGenerator.nullToStr()
, for the built-in conversion from
null
to str
.
KipperTargetBuiltInGenerator.undefinedToStr()
, for the built-in conversion from
undefined
to str
.
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.
0.10.3
, but was only added to the dev branch with the release of
0.11.0-alpha.1
i.e. 0.11.0-alpha.0
does not have this change).
VoidOrNullOrUndefinedPrimaryExpression
a constant expression and inherit from the
ConstantExpression
class. This means it's AST kind number is now also added to the
ASTConstantExpressionKind
type and its context class is also part of the
ParserConstantExpressionContext
type.
compiler/parser
to lexer-parser
.kipper/core/compiler/parser/parser-ast-mapping.ts
to
parse-rule-kind-mappings.ts
.
KipperParseStream
to KipperFileStream
including its file to
file-stream.ts
.
KipperParseFile
to KipperInputFile
including its file to
input-file.ts
.
FunctionCallPostfixTypeSemantics
to
FunctionCallExpressionTypeSemantics
.
FStringPrimaryExpressionSemantics.items
to atoms
.getTSFunction()
to genTSFunction()
.typeSpecifier
to typeSpecifierExpression
and its AST
class TypeSpecifier
to TypeSpecifierExpression
. This also includes
changing the name in the KipperTargetCodeGenerator
,
KipperTargetSemanticAnalyser
and KipperTargetBuiltInGenerator
classes.
identifierTypeSpecifier
to
identifierTypeSpecifierExpression
and its AST class
IdentifierTypeSpecifier
to IdentifierTypeSpecifierExpression
. This
also includes changing the name in the KipperTargetCodeGenerator
,
KipperTargetSemanticAnalyser
and KipperTargetBuiltInGenerator
classes.
genericTypeSpecifier
to
genericTypeSpecifierExpression
and its AST class
GenericTypeSpecifier
to GenericTypeSpecifierExpression
. This also
includes changing the name in the KipperTargetCodeGenerator
,
KipperTargetSemanticAnalyser
and KipperTargetBuiltInGenerator
classes.
typeofTypeSpecifier
to typeofTypeSpecifierExpression
and
its AST class TypeofTypeSpecifier
to TypeofTypeSpecifierExpression
.
This also includes changing the name in the KipperTargetCodeGenerator
,
KipperTargetSemanticAnalyser
and KipperTargetBuiltInGenerator
classes.
forLoopStatement
to forLoopIterationStatement
and its AST
class ForLoopStatement
to ForLoopIterationStatement
. This also
includes changing the name in the KipperTargetCodeGenerator
,
KipperTargetSemanticAnalyser
and KipperTargetBuiltInGenerator
classes.
whileLoopStatement
to whileLoopIterationStatement
and its
AST class WhileLoopStatement
to WhileLoopIterationStatement
. This also
includes changing the name in the KipperTargetCodeGenerator
,
KipperTargetSemanticAnalyser
and KipperTargetBuiltInGenerator
classes.
doWhileLoopStatement
to doWhileLoopIterationStatement
and
its AST class DoWhileLoopStatement
to DoWhileLoopIterationStatement
.
This also includes changing the name in the KipperTargetCodeGenerator
,
KipperTargetSemanticAnalyser
and KipperTargetBuiltInGenerator
classes.
kipper/core/compiler/parser/parser-ast-mapping.ts
to
parse-rule-kind-mappings.ts
.
ArrayLiteralPrimaryExpression
to ArrayPrimaryExpression
.ArrayLiteralPrimaryExpressionSemantics
to
ArrayPrimaryExpressionSemantics
.
ArrayLiteralPrimaryExpressionTypeSemantics
to
ArrayPrimaryExpressionTypeSemantics
.
TangledPrimaryTypeSemantics
to
TangledPrimaryExpressionTypeSemantics
.
DoWhileLoopStatementSemantics
to
DoWhileLoopIterationStatementSemantics
.
ParseData
to LexerParserData
.TargetASTNodeCodeGenerator.arrayLiteralExpression
to
arrayPrimaryExpression
.
TargetASTNodeSemanticAnalyser.listPrimaryExpression
to
arrayPrimaryExpression
.
FStringPrimaryExpressionSemantics.items
to atoms
.LexerParserData.parseStream
to fileStream
.kipper/core/utils.ts
to kipper/core/tools
and separated it into
multiple files & modules.
kipper/core/compiler/ast/root-ast-node.ts
to the
kipper/core/compiler/ast/nodes
module.
kipper/core/compiler/ast/ast-types.ts
to the new
kipper/core/compiler/ast/common
module.
InternalError
after calling the compiler (#462).
KipperCompiler
, where abortOnFirstError
didn't
precede recover
, meaning that instead of an error being thrown the failed result was
returned (As defined in the recover
behaviour, which is incorrect).
-t
shortcut flag was incorrectly shown for the command
help compile
. (#451)
(This is the same fix as in 0.10.3
, but was only added to the dev branch with the
release of 0.11.0-alpha.1
i.e. 0.11.0-alpha.0
still has this bug).
0.10.4
, but with one additional edge-case covered. This fix was only added to the dev
branch with the release of 0.11.0-alpha.1
i.e. 0.11.0-alpha.0
still has
this bug).
--abort-on-first-error
in favour of --no-recover
.
(#501).
analyse
in favor of the flag --dry-run
in the CLI
command compile
. (#532).
ConstantExpression
, its interfaces
ConstantExpressionSemantics
and ConstantExpressionTypeSemantics
, as they
were not really needed and unnecessarily added another level of complexity to the AST. All classes
which previously inherited from ConstantExpression
now inherit from
PrimaryExpression
instead.
executeKipperProgram
to Run
as a private function.KipperCompileResult
to new file compile-result.ts
in the same
directory.
KipperCompileResult.programCtx
can now be also undefined
, due to the
changed behaviour that now a KipperCompileResult
is also returned for syntax errors
(where it has no value).
--abort-on-first-error
in favour of --no-recover
.
#501.
@kipper/cli
:
input
, which contains all input-related handling functions and classes.output
, which contains the output-related handling functions and classes.prettifiedErrors
in @kipper/cli
, which applies standardised
error formatting to any thrown error.
KipperInternalError
, which does not have " - Report this bug to the
developer using the traceback!" as a suffix anymore.
kipper analyse
command
Finished code analysis in ...
to Done in ...
.
getFile
to getParseStream
.-t
shortcut flag was incorrectly shown for the command
help compile
. (#451)
KipperError.programCtx
, which contains, if
KipperError.tracebackData.errorNode
is not undefined, the program context of the
error.
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.
InternalError
after calling the compiler (#462).
KipperCompiler
, where abortOnFirstError
didn't
precede recover
, meaning that instead of an error being thrown the failed result was
returned (As defined in the recover
behaviour, which is incorrect).
@kipper/target-js
,
which implements the semantic analysis and code generation for JavaScript, and provides the class
KipperJavaScriptTarget
(TargetTS
available as alias), which can be used as
the target in the CompileConfig
. (#208).
@kipper/web
, which from now on will provide the
kipper-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 identifiers KipperJS
and KipperTS
in the web environment. (#86).
+=
, -=
, *=
,
%=
and /=
(#273).
++
, --
) expressions
(#272).
[]
,
[:]
), 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).
len()
, which returns the length of a string (In the
future also arrays). (#411).
continue
and break
for iteration statements.
(#269).
__name__
returning the name of the current file. This also
includes general support for built-in variables in the compiler. (#412).
null
and undefined
, and support for the constant
identifier void
, null
and undefined
.
-t/--target
to specify the target to use for a compilation or
execution.
"use strict";
in the TypeScript target to enforce the use of strict mode during
runtime.
TypeSemantics
to ASTNode
, which defines the type
data that the AST Node should evaluate during type checking.
run
and compile
:
--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.
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.
KipperWarning
, which is a subclass of KipperError
that is used to
indicate a warning. This replaces the use of KipperError
for warnings.
ReturnStatement
, which is a subclass of Statement
that represents a
return statement. This is not anymore included in the JumpStatement
class.
FunctionScope
, which is a subclass of Scope
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 of Type
and represents a raw
specified type during semantic analysis.
CheckedType
, which is an implementation of Type
and represents a
checked type during type checking, which also handles compatibility and error recovery for
undefined types.
MemberAccessExpression
, which is a subclass of Expression
that
represents a member access expression (Antlr4 rule memberAccessExpression
).
AnalysableASTNode
, which represents an AST node that can be semantically processed.
This class was created as a parent class for CompilableASTNode
, as a way to split
up the semantic analysis and code generation.
KipperWarningIssuer
, which is a class similar to
KipperSemanticChecker
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 the
innerScope
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 for
MemberAccessExpression
.
MemberAccessExpressionTypeSemantics
, which represents the type semantics for
MemberAccessExpression
.
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.
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 an UndefinedSemanticsError
.
CompilableASTNode.semanticTypeChecking()
, which performs type checking for the AST
node and its children nodes. This is called in the function
RootASTNode.semanticAnalysis
after
CompilableASTNode.semanticAnalysis()
.
CompilableASTNode.wrapUpSemanticAnalysis()
, which performs wrap-up semantic
analysis for the target of the AST node. This is called in the function
RootASTNode.semanticAnalysis
after
CompilableASTNode.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's checkforWarnings()
functions as well as the function of the parent
instance.
shouldRecoverFromError()
and handleSemanticError()
in
handle-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 a
MissingRequiredSemanticDataError
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 a
MissingRequiredSemanticDataError
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.
TypeData
, which represents the type data of an ASTNode
.NoTypeSemantics
, which hints that an ASTNode
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 for
KipperParam
.
KipperParam
, which represents a function parameter.JmpStatementType
, which represents all possible jump statement types e.g.
break
and continue
.
ASTDeclarationKind
, which is a union type of all possible
ParserASTNode.kind
values for a Declaration
AST node.
ASTExpressionKind
, which is a union type of all possible
ParserASTNode.kind
values for a Expression
AST node.
ASTStatementKind
, which is a union type of all possible
ParserASTNode.kind
values for a Statement
AST node.
ASTConstantExpressionKind
, which is a union type of all possible
ParserASTNode.kind
values for a ConstantExpression
AST node.
ParserConstantExpressionContext
, which is a union type of all possible
ParserASTNode.antlrRuleCtx
values for a ConstantExpression
AST node.
ASTTypeSpecifierExpressionKind
, which is a union type of all possible
ParserASTNode.kind
values for a TypeSpecifierExpression
AST node.
ParserTypeSpecifierExpressionContext
, which is a union type of all possible
ParserASTNode.antlrRuleCtx
values for a TypeSpecifierExpression
AST
node.
ASTUnaryExpressionKind
, which is a union type of all possible
ParserASTNode.kind
values for a UnaryExpression
AST node.
ParserUnaryExpressionContext
, which is a union type of all possible
ParserASTNode.antlrRuleCtx
values for a UnaryExpression
AST node.
ASTComparativeExpressionKind
, which is a union type of all possible
ParserASTNode.kind
values for a ComparativeExpression
AST node.
ParserComparativeExpressionContext
, which is a union type of all possible
ParserASTNode.antlrRuleCtx
values for a ComparativeExpression
AST
node.
ConstructableASTStatementClass
, which is a union type of all possible
Statement
AST node classes.
ASTLogicalExpressionKind
, which is a union type of all possible
ParserASTNode.kind
values for a LogicalExpression
AST node.
ParserLogicalExpressionContext
, which is a union type of all possible
Parserement
AST node classes.
ConstructableASTExpressionClass
, which is a union type of all possible
Expression
AST node classes.
ConstructableASTDeclarationClass
, which is a union type of all possible
Declaration
AST node classes.
ConstructableASTNodeClass
, which is a union type of all possible
ASTNode
AST node classes.
ConstructableASTStatement
, which is a union type of all possible
Statement
AST node instances.
ConstructableASTExpression
, which is a union type of all possible
Expression
AST node instances.
ConstructableASTDeclaration
, which is a union type of all possible
Declaration
AST node instances.
ConstructableASTNode
, which is a union type of all possible
ASTNode
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 from
ParserASTMapping
.
ConstructableASTKind
, which is the same as ASTKind
, but removes any
kind value that does not have a corresponding AST node class.
KipperReferenceableFunction
, which represents a function that can be referenced by
a FunctionCallExpression
.
ASTNodeParserContext
, which represents a union of all possible
ParserASTNode.antlrRuleCtx
values implemented in the KipperParser
that
have a corresponding AST node class.
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 overwrites
recover
per default.
RootASTNode.target
, which returns the KipperCompileTarget
of the
program ctx the root AST node is in.
RootASTNode.codeGenerator
, which returns the
KipperTargetCodeGenerator
of the program ctx the root AST node is in.
RootASTNode.semanticAnalyser
, which returns the
KipperTargetSemanticAnalyser
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
and RootASTNode.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 the
KipperParser
rule number, as defined by KipperParser.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.
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 a KipperParser
rule ctx instance.
kipperRuntimeBuiltInVariables
, which contains the built-in variables of the Kipper
runtime.
@kipper/target-ts
, which implements the semantic analysis and code generation for
TypeScript, and provides the class KipperTypeScriptTarget
(TargetTS
available as alias), which can be used as the target in the CompileConfig
.
__kipper
and the global object property
globalThis.__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.
call
keyword optional. This allows for
simplified function calls, such as print("Hello world!");
.
Error
instead of KipperError
.Scope
and its implementing classes to a hashmap
implementation.
CompilableASTNode
functions primarySemanticAnalysis
,
primarySemanticTypeChecking
and targetSemanticAnalysis
and made them
possibly undefined if there is nothing to check. This is to improve performance and not call an
async function unnecessarily.
Kipper.g4
into KipperLexer.g4
and
KipperParser.g4
.
StatementASTNodeFactory
,
DeclarationASTNodeFactory
and ExpressionASTNodeFactory
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. The create
function is now instance-based (not
static anymore) as well.
KipperParseStream
to allow either an CharPointCharStream
or
a string
as input, but not allow a mismatch content between the two.
KipperFileASTGenerator
(previously
KipperFileListener
) and removed unnecessary code.
EvaluatedCompileOptions
to EvaluatedCompileConfig
.UnableToDetermineMetadataError
to UndefinedSemanticsError
.ReadOnlyAssignmentTypeError
to ReadOnlyWriteTypeError
.InvalidAssignmentTypeError
to AssignmentTypeError
.InvalidArgumentTypeError
to ArgumentTypeError
.InvalidArithmeticOperationTypeError
to ArithmeticOperationTypeError
.
InvalidReturnTypeError
to FunctionReturnTypeError
.UndefinedIdentifierError
to UndefinedReferenceError
.UnknownIdentifierError
to UnknownReferenceError
.FunctionDeclarationSemantics.args
to params
.KipperTypeChecker.argumentTypesMatch
to validArgumentValue
.ListPrimaryExpression
to ArrayLiteralPrimaryExpression
.FunctionCallPostfixExpression
to FunctionCallExpression
.antlrDefinitionCtxType
to ParserDeclarationCtx
.antlrExpressionCtxType
to ParserExpressionCtx
.antlrStatementCtxType
to ParserStatementCtx
.ParserExpressionCtx
to ParserExpressionContext
.ParserStatementCtx
to ParserStatementContext
.ParserDeclarationCtx
to ParserDeclarationContext
.KipperFileListener
to KipperFileASTGenerator
.KipperProgramContext.addError
to reportError
.kipperRuntimeBuiltIns
to kipperRuntimeBuiltInFunctions
.kipperInternalBuiltIns
to kipperInternalBuiltInFunctions
.KipperSemanticsAsserter.getReference
to class
KipperSemanticChecker
.
KipperSemanticsAsserter.getExistingReference
to class
KipperSemanticChecker
.
indentLines
to file tools.ts
of
@kipper/target-js
.
CompilableASTNode.semanticAnalysis
to AnalysableASTNode
.
CompilableASTNode.semanticTypeChecking
to AnalysableASTNode
.
CompilableASTNode.wrapUpSemanticAnalysis
to
AnalysableASTNode
.
CompilableASTNode.recursivelyCheckForWarnings
to
AnalysableASTNode
.
CompilableASTNode.recursivelyCheckForWarnings
to
AnalysableASTNode
.
CompilableASTNode.primarySemanticAnalysis
to
AnalysableASTNode
.
CompilableASTNode.primarySemanticTypeChecking
to
AnalysableASTNode
.
CompilableASTNode.checkForWarnings
to
AnalysableASTNode
.
CompilableASTNode.programCtx
to AnalysableASTNode
.CompilableASTNode.compileConfig
to AnalysableASTNode
.CompilableASTNode.errors
to AnalysableASTNode
.CompilableASTNode.addError
to AnalysableASTNode
.CompilableASTNode.hasFailed
to AnalysableASTNode
.[]
).[]
).KipperParseStream
multiple times would result in the
CodePointCharStream
being empty.
;
) in a compound statement.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 class
KipperWarning
.
KipperCharType
(char
) and its grammar implementation, meaning all string
types from now on will only be of type str
. 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
and kipperReturnTypes
, as they are always identical to
the KipperType
and kipperTypes
respectively.
FunctionReturnTypeError
, as it is obsolete since all return types are valid.Scope.functions
(replaced by hash-map implementation of Scope
).Scope.variables
(replaced by hash-map implementation of Scope
).Scope.getVariable
(replaced by hash-map implementation of Scope
).
Scope.getFunction
(replaced by hash-map implementation of Scope
).
KipperError.antlrCtx
, as it was replaced by
TracebackMetadata.errorNode
.
KipperTypeChecker.validReturnType
, as it is obsolete due to the absence of
KipperReturnType
.
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 by
builtInFunctionReferences
and builtInVariableReferences
).
KipperProgramConext.registerBuiltIns
(replaced by
registerBuiltInFunctions
and registerBuiltInVariables
).
CompileConfig.builtIns
(replaced by builtInFunctions
and
builtInVariables
).
CompileConfig.extendBuiltIns
(replaced by extendBuiltInFunctions
and
extendBuiltInVariables
).
arraySpecifierExpression
(ArraySpecifierExpression
), which was
made obsolete with the addition of
bracketNotationMemberAccessExpression
(BracketNotationMemberAccessExpression
).
kipper
, which exports
@kipper/core
allowing the kipper
package to be used in projects.
!=
(Not Equal Operator)==
(Equal Operator)>
(Greater than Operator)>=
(Greater or equal to Operator)<
(Less than Operator)<=
(Less or equal to Operator)&&
(Logical And Operator)||
(Logical Or Operator)!
(Logical NOT Operator)+
(Plus Operator)-
(Minus Operator)KipperError
instances to be warnings
if isWarning
is set to true and implementing AST-based checks for warnings using the
new function CompilableASTNode.checkForWarnings()
. (#199)
-w/--warnings
in the commands compile
, run
and
analyse
, which enables logger warnings. (#199)
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.
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 a antlrRuleCtx
.
ExpressionASTNodeFactory
, which is a factory that creates an expression instance
based on a antlrRuleCtx
.
StatementASTNodeFactory
, which is a factory that creates a statement instance based
on a antlrRuleCtx
.
KipperUnaryOperator
KipperLogicalAndOperator
KipperLogicalOrOperator
KipperLogicalOperator
KipperEqualityOperator
KipperRelationalOperator
KipperComparativeOperator
KipperUnaryModifierOperator
KipperIncrementOrDecrementOperator
KipperNegateOperator
KipperSignOperator
kipperUnaryOperators
kipperLogicalAndOperator
kipperLogicalOrOperator
kipperLogicalOperator
kipperEqualityOperators
kipperRelationalOperators
kipperComparativeOperators
kipperIncrementOrDecrementOperators
kipperNegateOperators
kipperSignOperators
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 a
KipperError
.
CompilableASTNode.checkForWarnings()
, which checks for warnings in an AST Node.
KipperTypeChecker.validRelationalExpression()
, which ensures a
RelationalExpression
is semantically valid.
KipperTypeChecker.validUnaryExpression()
, which ensures a
UnaryExpression
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.
CompileConfig.warnings
, which if set to true enables warnings and stores them in
KipperCompileResult.warnings
.
EvaluatedCompileOptions.warnings
, which if set to true enables warnings and stores
them in KipperCompileResult.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.
KipperSemanticChecker.arithmeticExpressionValid()
to
KipperTypeChecker
and renamed it to validArithmeticExpression()
.
singleTypeSpecifier
to identifierTypeSpecifier
and its
associated class to IdentifierTypeSpecifierExpression
.
SingleTypeSpecifierExpression
to IdentifierTypeSpecifierExpression
.
ParserASTNode.getTokenChildren()
to getAntlrRuleChildren()
.Scope.localVariables
to variables
.Scope.localFunctions
to functions
.getDefinitionInstance
, which was replaced with
DefinitionASTNodeFactory
.
getExpressionInstance
, which was replaced with
ExpressionASTNodeFactory
.
getStatementInstance
, which was replaced with StatementASTNodeFactory
.
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).
KipperProgramContext.registerGlobals()
to registerBuiltIns
.InvalidConversionError
to InvalidConversionTypeError
InvalidArithmeticOperationError
to InvalidArithmeticOperationTypeError
InvalidArithmeticOperationTypeError
to
TypeError
.
InvalidAmountOfArgumentsError
.NotImplemented
errors from KipperFileListener.ts
with
KipperNotImplementedError
errors, which are now thrown inside the
primarySemanticAnalysis()
functions of the affected statements.
Kipper.g4
, which resulted in spaces being syntactically invalid
in an empty function argument list, e.g. def func( ) -> void;
was invalid before.
nestedParenthesesBlock
.str
as num
num
as str
bool
as str
bool
as num
true
and false
, which automatically evaluate
to the type bool
and can be used in expressions. (true
and
false
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 class
BoolPrimaryExpression
, a new target-specific semantics function
KipperTargetSemanticAnalyser.boolPrimaryExpression
and target-specific translation
function KipperTargetCodeGenerator.boolPrimaryExpression
. (#134)
KipperOptimiser
, which removes any function definitions that are not used (#159).
KipperCompileTarget.builtInGenerator
, which will store the built-in generator
for each target.
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 as str
.
GenericTypeSpecifierExpression
, which represents a generic type constant, such as
type<T>
. (Functionality not implemented yet! Planned for v0.12)
TypeofTypeSpecifierExpression
, which represents a dynamically evaluated type, such
as typeof("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 by KipperTargetSemanticAnalyser
and
KipperAsserter
.
KipperOptimiser
, which handles code optimisation for a Kipper program.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.
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.
type
, which represents the type of a Kipper type.kipperSupportedConversions
, which is an array containing multiple tuples
representing allowed conversions in Kipper.
CompileConfig
option optimisationOptions
, which contains the
configuration for the KipperOptimiser
.
-b/--[no-]optimise-builtins
and
-i/--[no-]optimise-internals
to the @kipper/cli
for enabling internal and
built-in functions optimisation.
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.
kipper/core/src/targets/typescript
and
split up the classes into their own files.
KipperProgramContext.generateRequirements()
. This function generates the built-ins for
a program using its KipperTargetBuiltInGenerator
, which is specified in the
KipperCompileTarget
.
@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.
builtIns
to kipperRuntimeBuiltIns
.semantic-analyser.ts
to target-semantic-analyser.ts
.ParserASTNode.ensureTokenChildrenExist()
to getTokenChildren()
.ParserASTNode.ensureSemanticDataExists()
to getSemanticData()
.KipperError.setMetadata()
to KipperError.setTracebackData()
.KipperAsserter
to KipperSemanticsAsserter
.TargetTokenCodeGenerator
to TargetASTNodeCodeGenerator
.TargetTokenSemanticAnalyser
to TargetASTNodeSemanticAnalyser
.CompilerEvaluatedOptions
to EvaluatedCompileOptions
.KipperProgramContext.processedParseTree
to abstractSyntaxTree
.KipperProgramContext.builtInGlobals
to builtIns
.CompileConfig.globals
to builtIns
.CompileConfig.extendGlobals
to extendBuiltIns
.KipperCompileResult.write()
.@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.
Scope
,
GlobalScope
and LocalScope
. These classes now handle local variables and
functions and implement a standard interface for handling declarations and definitions.
@kipper/cli
flag names from camelCase to dash-case.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.
UnknownFunctionIdentifierError
UnknownVariableIdentifierError
KipperSemanticChecker.functionIsDefined
KipperSemanticChecker.variableIsDefined
BuiltInFunction.handler
as the core compiler will not handle code generation of Kipper
built-ins (like for example print
) anymore.
"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.
InvalidOverwriteError
, as all errors it represented are now subclasses of
IdentifierError
.
KipperProgramContext
, as they were replaced by the new scope
handling classes:
getGlobalFunction()
getGlobalIdentifier()
getGlobalVariable()
addGlobalVariable()
determineScope()
, as the scope handling was moved to
CompilableASTNode.scope
.
AssignmentExpression
and
VariableDeclaration
.
call print(identifier)
identifier + identifier
or
identifier + 5
-s/--stringCode
, which can be used as a replacement for the
argument file
. (#100).
This flag is available for kipper analyse
, kipper compile
and
kipper run
)
VariableDeclarationSemantics.value
, which represents the expression that was
assigned in the definition. This field is undefined
if
VariableDeclarationSemantics.isDefined
is false
.
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 of
primarySemanticAnalysis()
.
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
and KipperSemanticChecker
, which perform specialised
semantic checking and verify logical integrity and cohesion. These two classes replace
CompileAssert
.
InvalidAssignmentError
, which is thrown when an invalid assignment is used.KipperInvalidInputError
, which is thrown when passing invalid input to the Kipper
cli.
utf16le
encoding.
utf16le
encoding. From now on a buffer
will be created using the proper encoding (also for ascii
and utf8
) that
should be properly writable to a file.
N + N + N
) resulting in incomplete TypeScript code.
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 as
typescript
.
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.
InvalidTypeError
to TypeError
.KipperProgramContext.addNewGlobalScopeEntry
to
addGlobalVariable()
.
CompoundStatement.addNewLocalVariable
to addLocalVariable()
.
@types/node
as a dependency for @kipper/cli
.~
(Accepting patches, but
not new features). E.g. @kipper/cli
requires "@kipper/core": "~0.6"
NumberPrimaryExpression
).
MultiplicativeExpression
and AdditiveExpression
.
ExpressionSemantics
, which is the base for all expression semantics.
ArithmeticExpressionSemantics
which is used as a parent for
MultiplicativeExpressionSemantics
and AdditiveExpressionSemantics
.
args
in FunctionCallPostfixExpressionSemantics
, which contains the
Expression
instances representing the arguments of a function call.
getTokenIntervalSource()
, which fetches the source code for an interval of two
Token
instances.
getParseTreeSource()
, which fetches the source code for a parse tree.CompilableASTNode.ensureTokenChildrenExist()
, which throws an
UnableToDetermineMetadataError
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()
and
CompileAssert.getExistingReference()
for fetching reference variables based on an
identifier.
CompoundStatement.getLocalVariable()
and
CompoundStatement.getVariableRecursively()
for fetching a variable based on an
identifier inside a CompoundStatement
/KipperScope
.
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, like
char
and str
.
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.
defaultWebBuiltIns
and defaultNodeBuiltIns
, which provide the default
built-in functions for Kipper. Kipper will attempt from now on to detect whether the environment
is a browser and use defaultWebBuiltIns
in that case and otherwise default to
defaultNodeBuiltIns
.
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 both
kipperAdditiveOperators
and kipperMultiplicativeOperators
.
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, like
char
and str
.
getTokenSource
to getParseRuleSource
, and replaced the original
function with getTokenSource
that only fetches the code for a single
Token
instance.
CompilableASTNode.antlrCtx
to antlrRuleCtx
.functionIdentifierNotUsed
to functionIdentifierNotDeclared
.variableIdentifierNotUsed
to variableIdentifierNotDeclared
.name
to identifier
in interface
BuiltInFunctionArgument
.
0.8.0
):
variableIsDefined
functionIsDefined
UnknownVariableIdentifierError
UnknownFunctionIdentifierError
ArgumentExpressionListExpression
and its abstract translation
function in KipperTargetCodeGenerator
.
RootFileParseToken.compileCtx
.target
in CompileConfig
, which defines the compilation target
for a Kipper program.
KipperProgramContext.target
, which defines the
compilation target for the program.
TargetTokenSemanticAnalyser
, which represents a function type that
semantically analyses a CompilableASTNode
.
TargetTokenCodeGenerator
, which represents a function type that semantically
analyses a CompilableASTNode
.
KipperTargetCodeGenerator
, which defines the functions
that convert the Kipper code into a specific target language.
KipperTargetSemanticAnalyser
, which can define
additional semantic analysis logic for a compilation target.
KipperCompileTarget
which defines the functions and classes for how to handle the
translation to a specific target.
TypeScriptTarget
, which defines the default target for Kipper.targetCodeGenerator
and targetSemanticAnalysis
, which must
be defined in child classes of abstract base class CompilableASTNode
.
target
, codeGenerator
and semanticAnalyser
in
class CompilableASTNode
.
primarySemanticAnalysis
and
targetSemanticAnalysis
, which are split to separate the core/primary semantic analysis
and the target specific semantic analysis.
KipperVoidType
, KipperNumType
, KipperStrType
,
KipperCharType
, KipperBoolType
and KipperListType
, which
represent Kipper available types in the Kipper language. core/primary semantic analysis and the
target specific semantic analysis.
CompileAssert.getExistingFunction()
for fetching a function and
throwing an error if it does not exist.
version
, which returns the currently installed Kipper version.update
, which updates the CLI if a new version is available.update
, which updates the CLI if a new release is
available.
warn-if-update-available
, which will display a warning when the CLI is used
that a new version can be installed.
@kipper/base
as it is now replaced with @kipper/core
.@kipper/cli
bug causing logging messages to only contain "anonymous-script".
RootFileParseToken.compileCtx
function and added new two
functions RootFileParseToken.semanticAnalysis()
, which semantically analysis the code
for basic semantics and target-specific semantics, and RootFileParseToken.translate()
,
which translates the code into the specific target.
CompilableASTNode.semanticAnalysis()
and
CompilableASTNode.translateCtxAndChildren()
non-abstract and implemented basic
processing algorithm to run the code from CompilableASTNode.targetCodeGenerator
and
CompilableASTNode.targetSemanticAnalysis
.
CompilableASTNode
children classes and created for
each child class a representing semantics class defining the metadata for the token.
UnknownFunctionIdentifier
to UnknownFunctionIdentifierError
.
CompileAssert.assertTypeExists
to typeExists
.CHANGELOG.md
from @kipper/cli
and @kipper/core
, as it is
now only shipped with kipper
.
KipperLogger.reportError()
for reporting and logging errors.KipperAntlrErrorListener.getSourceCode()
for fetching the source code for
a syntax error.
KipperSyntaxError
(#42).
line
, col
, filePath
and
tokenSrc
in KipperError
, which returns the metadata for the error.
offendingSymbol
is
undefined
the entire line of code is set as tokenSrc
(#36).
KipperParseStream.lines
returning all lines in the source file as an
array.
CompileAssert.error()
to CompileAssert.throwError()
and
added error logging for the error passed as argument.
KipperErrorListener
to KipperAntlrErrorListener
.InternalKipperError
to KipperInternalError
.KipperCompiler.errorListener
, as due to (#42) the KipperAntlrErrorListener
will have to be initialised per compilation, not per
compiler instance.
Utils
and moved its methods into the global scope of the file to allow the
following import scheme import * as Utils from "@kipper/core/utils"
, where the user can
themselves define the wanted scope identifier.
KipperErorr.getTraceback()
and
KipperError.setMetadata
.
Utils
with new function getTokenSource()
and
determineScope()
.
FunctionDefinitionAlreadyExistsError
and
VariableDefinitionAlreadyExistsError
, which are raised if definition rules are
violated.
index.ts
.InvalidOverwriteError
and
IdentifierError
.
KipperInternalError
, which is raised in case there is an internal error/bug.DuplicateVariableDefinitionError
to
IdentifierAlreadyUsedByVariableError
DuplicateFunctionDefinitionError
to
IdentifierAlreadyUsedByFunctionError
antlrContext
to antlrCtx
across all files.assert
system:
KipperProgramContext.assert(ctx).ASSERT_FUNC()
.
semanticAnalysis()
step.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!)
CompilableASTNode
to determine semantics and semantic types using
generic classes. This means all semantic data is now stored using the get and setter
CompilableASTNode.semanticData
.
CompilableASTNode.compileCtx()
added in 0.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.
_currentScope
in KipperFileListener
, as the
scope handling system has been replaced with a dynamic determination using
semanticAnalysis()
.
CompileAssert
, which is used to assert certain compiler-required
truths, which, if false, trigger corresponding errors.
UnknownVariableDefinition
and UnknownFunctionDefinition
.CompilableASTNode.tokenStream
, which returns the
programCtx.tokenStream
instance.
ArgumentExpressionList
representing an argument list
inside function calls.
KipperCompileResult.write()
, which creates a human-readable string from
the generated source code.
logLevel
, which defines which messages
should be logged. (Only messages with equal or higher importance will be logged).
name
property
explicitly.
DuplicateIdentifierError
with
DuplicateVariableDefinitionError
and DuplicateFunctionDefinitionError
.
NoBuiltInOverwriteError
to BuiltInOverwriteError
.getMetadata
functions /tokens/
instance-methods, removing all
required parameters.
Array<string>
to
Array<Array<string>>
, where each nested array represents a line combined of
string tokens.
CompilableASTNode
.
compileCtx
to Array<string>
in children classes
of Expression
.
CompilableASTNode.semanticAnalysis()
and
CompilableASTNode.translateCtxAndChildren()
to protected
, as they will
be replaced and tied together using CompilableASTNode.compileCtx()
.
RootParseToken.translateCtxAndChildren
with
RootParseToken.compileCtx()
.
LogLevel
to numeric values, which can be translated into strings
using getLogLevelString()
.
RootParseToken.semanticAnalysis()
and
RootParseToken.translateCtxAndChildren
scope
property to all
Statement
classes and creating a tracking variable called _currentScope
in
KipperFileListener
, which will be updated while processing the parse tree.
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.
BuiltInOverwriteError
, UnableToDetermineMetadataError
and
UnknownTypeError
.
ScopeDeclaration
, which is the parent class for the
already existing ScopeDeclaration
and the added ScopeFunctionDeclaration
.
KipperProgramContext.globalScope
, which contains all global variables and
function definitions.
ScopeDeclaration
to ScopeDeclaration
and updated its
constructor to require a token (VariableDeclaration
instance), which will automatically
set the properties (identifier, storage type, value type, scope and state).
KipperParseStream
to
stringContent, name, charStream
, and set name
to default to
"anonymous-script"
.
CompoundStatement
children behaviour, by adding a new array
localScope
, which will store the metadata for all variables exclusively available in
that compound statement.
tslib
KipperFileListener.itemBuffer
, which will contain the generated TypeScript code-lines,
that were generated in the walking step.
KipperFileContext
, which will serve as the base class, where the compilation data
is stored.
kipper
in index.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 inside
KipperFileContext.typescriptCode
to allow reusing code instead of unnecessarily
generating code again.
LogLevel.UNKNOWN
as the default log level for LogLevel
.KipperLogger.levels
as a static variable to access the enum LogLevel
.
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 using
semanticAnalysis()
and translate it to TypeScript using compileCtx()
.
parser
, lexer
, errorHandler
and
tokenStream
inside the class KipperFileContext
.
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
interface BuiltInFunction
. (In work!)
**
(Power-to) as a valid arithmetic expression.RuntimeCompileConfig
and CompileConfig
, which may be passed
onto KipperCompile.compile()
to configure the compilation behaviour.
/compiler/tokens
, which contains the parse token
implementations.
print
that will be available inside a Kipper program
per default (unless forcibly changed).
ScopeDeclaration
representing a declaration/entry inside a scope. This is
used primarily inside KipperProgramContext
, which uses it to keep track of global
definitions and also CompoundStatement
s, which may have children definitions.
KipperStorageType
and
KipperType
.
KipperCompiler.parse()
to KipperFileContext
, which wraps
the generated parse tree.
KipperCompileResult
, which will now store the
programCtx: KipperFileContext
and result: string[]
of a compilation.
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 onto KipperSyntaxError<T>
.
LogLevel
, which now returns string-representations of the log level.
initializer
rule in Kipper.g4 and removed invalid designator rules.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).
KipperFileContext
to KipperProgramContext
, which will now handle
the entire compilation and store its meta-data.
KipperStreams
and its functions.LogLevelNames
, as now the enum LogLevel
per default
returns the names of the level.
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.
streamName
in KipperCompiler.syntaxAnalyse()
and
KipperCompiler.compile()
.
Broken version!
kipper-standalone.js
run
command for running a compiled file or compiling and running a file. (This is
still in development).
compile
command for compiling a file into it's js-counterpart with its typescript
types added.
KipperParseStream
, which implements a basic Utf-16 stream.
[]
initializers for lists in Kipper.g4.multiItemTypeSpecifier
, which use the
identifier<T>
syntax (for lists specifically).
typeof(V)
(typeofTypeSpecifier
) syntax for
typeSpecifier
expressions.
identifier as typeSpecifier
syntax.for(INIT_EXPRESSION; CONDITION, LOOP_EXPRESSION) STATEMENT
syntax.
LogLevelNames
, which will map LogLevel
enum values to constant
strings (e.g. LogLevel.CRITICAL
-> "CRITICAL"
).
KipperLogger
, which will now only use an
emitHandler
, 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.
KipperParseFile
, which will be implemented in the NodeJS CLI implementation for Kipper
oclif
environment with the appropriate tests/test/module
for module specific tests using mocha
KipperErrorListener<Token>
for listening to KipperParser
and
KipperLexer
errors
ParserFile
for implementing the stream that may be used for
KipperCompiler.parser()
commands
(for oclif
) and
compiler
(for the compiler source-code)