Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.11.0 #655

Merged
merged 332 commits into from
Jul 10, 2024
Merged

v0.11.0 #655

merged 332 commits into from
Jul 10, 2024

Conversation

Luna-Klatzer
Copy link
Member

@Luna-Klatzer Luna-Klatzer commented Jul 10, 2024

What type of change does this PR perform?

  • Info or documentation change (Non-breaking change that updates repo info files (e.g. README.md, CONTRIBUTING.md, etc.) or online documentation)
  • Website (Change that changes the design or functionality of the websites or docs)
  • Development or internal changes (These changes do not add new features or fix bugs, but update the code in other ways)
  • Bug fix (Non-breaking change which fixes an issue)
  • New feature (Non-breaking change which adds functionality)
  • Breaking change (Major bug fix or feature that would cause existing functionality not to work as expected.)
  • Requires a documentation update, as it changes language or compiler behaviour

Summary

New major development version 0.11.0, which includes many optimisations in the core language, rewrites the core AST node system and adds additional expressions and statements.

Detailed Changelog

Added

  • 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 in compile, which only compiles the program and does not write any outputs. (#532).
  • New valid conversions:
    • void to str.
    • null to str.
    • undefined to str.
  • 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 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.
  • 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 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.
  • 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, 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.
  • New types:
    • InverseMap, which inverts a map by swapping the keys and values.
  • New functions:
    • 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.

Changed

  • 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 of 0.11.0-alpha.1
    i.e. 0.11.0-alpha.0 does not have this change).
  • Made 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.
  • Renamed:
    • Module compiler/parser to lexer-parser.
    • File kipper/core/compiler/parser/parser-ast-mapping.ts to parse-rule-kind-mappings.ts.
    • Class KipperParseStream to KipperFileStream including its file to file-stream.ts.
    • CLI Class KipperParseFile to KipperInputFile including its file to input-file.ts.
    • Class FunctionCallPostfixTypeSemantics to FunctionCallExpressionTypeSemantics.
    • Field FStringPrimaryExpressionSemantics.items to atoms.
    • Function getTSFunction() to genTSFunction().
    • Grammar Rule typeSpecifier to typeSpecifierExpression and its AST class TypeSpecifier to
      TypeSpecifierExpression. This also includes changing the name in the KipperTargetCodeGenerator,
      KipperTargetSemanticAnalyser and KipperTargetBuiltInGenerator classes.
    • Grammar Rule identifierTypeSpecifier to identifierTypeSpecifierExpression and its AST class
      IdentifierTypeSpecifier to IdentifierTypeSpecifierExpression. This also includes changing the name in the
      KipperTargetCodeGenerator, KipperTargetSemanticAnalyser and KipperTargetBuiltInGenerator classes.
    • Grammar Rule genericTypeSpecifier to genericTypeSpecifierExpression and its AST class GenericTypeSpecifier to
      GenericTypeSpecifierExpression. This also includes changing the name in the KipperTargetCodeGenerator,
      KipperTargetSemanticAnalyser and KipperTargetBuiltInGenerator classes.
    • Grammar Rule typeofTypeSpecifier to typeofTypeSpecifierExpression and its AST class TypeofTypeSpecifier to
      TypeofTypeSpecifierExpression. This also includes changing the name in the KipperTargetCodeGenerator,
      KipperTargetSemanticAnalyser and KipperTargetBuiltInGenerator classes.
    • Grammar Rule forLoopStatement to forLoopIterationStatement and its AST class ForLoopStatement to
      ForLoopIterationStatement. This also includes changing the name in the KipperTargetCodeGenerator,
      KipperTargetSemanticAnalyser and KipperTargetBuiltInGenerator classes.
    • Grammar Rule whileLoopStatement to whileLoopIterationStatement and its AST class WhileLoopStatement to
      WhileLoopIterationStatement. This also includes changing the name in the KipperTargetCodeGenerator,
      KipperTargetSemanticAnalyser and KipperTargetBuiltInGenerator classes.
    • Grammar Rule doWhileLoopStatement to doWhileLoopIterationStatement and its AST class
      DoWhileLoopStatement to DoWhileLoopIterationStatement. This also includes changing the name in the
      KipperTargetCodeGenerator, KipperTargetSemanticAnalyser and KipperTargetBuiltInGenerator classes.
    • File kipper/core/compiler/parser/parser-ast-mapping.ts to parse-rule-kind-mappings.ts.
    • Class ArrayLiteralPrimaryExpression to ArrayPrimaryExpression.
    • Interface ArrayLiteralPrimaryExpressionSemantics to ArrayPrimaryExpressionSemantics.
    • Interface ArrayLiteralPrimaryExpressionTypeSemantics to ArrayPrimaryExpressionTypeSemantics.
    • Interface TangledPrimaryTypeSemantics to TangledPrimaryExpressionTypeSemantics.
    • Interface DoWhileLoopStatementSemantics to DoWhileLoopIterationStatementSemantics.
    • Interface ParseData to LexerParserData.
    • Method TargetASTNodeCodeGenerator.arrayLiteralExpression to arrayPrimaryExpression.
    • Method TargetASTNodeSemanticAnalyser.listPrimaryExpression to arrayPrimaryExpression.
    • Field FStringPrimaryExpressionSemantics.items to atoms.
    • Field LexerParserData.parseStream to fileStream.
  • Moved:
    • 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.

Fixed

  • Redeclaration bug causing an InternalError after calling the compiler (#462).
  • Compiler argument bug in 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).
  • Bug of invalid underline indent in error traceback (#434).
  • CLI bug where the -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).
  • 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 of 0.11.0-alpha.1 i.e. 0.11.0-alpha.0 still has this bug).

Removed

  • 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 command compile. (#532).
  • Removed AST parent class 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.

Does this PR create new warnings?

None.

Linked issues or PRs

…o-v0-11

Sync bug fixes for issues #435, #451 & #491 to `v0.11`
Signed-off-by: Luna <luna.klatzer@gmail.com>
# Conflicts:
#	kipper/cli/pnpm-lock.yaml
@Luna-Klatzer Luna-Klatzer added release New release of the Kipper module. skip changelog Do not include in the changelog when a new release is drafted labels Jul 10, 2024
@Luna-Klatzer Luna-Klatzer added this to the v0.11.0 milestone Jul 10, 2024
@Luna-Klatzer Luna-Klatzer self-assigned this Jul 10, 2024
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 82.61456% with 258 lines in your changes missing coverage. Please review.

Project coverage is 84.29%. Comparing base (16cb772) to head (936ac59).
Report is 5 commits behind head on main.

Files Patch % Lines
kipper/cli/src/commands/new.ts 80.00% 9 Missing and 3 partials ⚠️
kipper/cli/src/decorators.ts 31.25% 11 Missing ⚠️
...e/src/compiler/ast/nodes/expressions/expression.ts 65.62% 10 Missing and 1 partial ⚠️
...ct-primary-expression/object-primary-expression.ts 37.50% 10 Missing ⚠️
...mary-expression/object-property/object-property.ts 33.33% 10 Missing ⚠️
kipper/cli/src/prompt-module.ts 40.00% 9 Missing ⚠️
kipper/cli/src/commands/run.ts 52.94% 8 Missing ⚠️
kipper/config/src/kipper-config-interpreter.ts 90.00% 2 Missing and 6 partials ⚠️
kipper/config/src/tools.ts 42.85% 4 Missing and 4 partials ⚠️
...ore/src/compiler/analysis/analyser/type-checker.ts 70.37% 4 Missing and 4 partials ⚠️
... and 39 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #655      +/-   ##
==========================================
+ Coverage   83.88%   84.29%   +0.40%     
==========================================
  Files          66      222     +156     
  Lines        2066     3915    +1849     
  Branches      252      435     +183     
==========================================
+ Hits         1733     3300    +1567     
- Misses        217      489     +272     
- Partials      116      126      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Luna-Klatzer Luna-Klatzer merged commit ef0300a into main Jul 10, 2024
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release New release of the Kipper module. skip changelog Do not include in the changelog when a new release is drafted
Projects
Development

Successfully merging this pull request may close these issues.

3 participants