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.13.0-alpha.2 #724

Merged
merged 5 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ authors:
identifiers:
- type: url
value: >-
https://github.com/Kipper-Lang/Kipper/releases/tag/v0.13.0-alpha.1
description: The GitHub release URL of tag 0.13.0-alpha.1
https://github.com/Kipper-Lang/Kipper/releases/tag/v0.13.0-alpha.2
description: The GitHub release URL of tag 0.13.0-alpha.2
repository-code: 'https://github.com/Kipper-Lang/Kipper/'
url: 'https://kipper-lang.org'
abstract: >-
Expand All @@ -39,6 +39,6 @@ keywords:
- oop-programming
- type-safety
license: GPL-3.0-or-later
license-url: 'https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/LICENSE'
version: 0.13.0-alpha.1
license-url: 'https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/LICENSE'
version: 0.13.0-alpha.2
date-released: '2025-02-26'
12 changes: 6 additions & 6 deletions kipper/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $ npm install -g @kipper/cli
$ kipper COMMAND
running command...
$ kipper (--version)
@kipper/cli/0.13.0-alpha.1 linux-x64 node-v23.4.0
@kipper/cli/0.13.0-alpha.2 linux-x64 node-v23.4.0
$ kipper --help [COMMAND]
USAGE
$ kipper COMMAND
Expand Down Expand Up @@ -111,7 +111,7 @@ EXAMPLES
kipper compile -t ts ./path/to/file.kip -o build/ -e utf16le --warnings --log-timestamp
```

_See code: [src/commands/compile.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/compile.ts)_
_See code: [src/commands/compile.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/compile.ts)_

## `kipper help [COMMAND]`

Expand All @@ -128,7 +128,7 @@ OPTIONS
--all see all commands in CLI
```

_See code: [src/commands/help.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/help.ts)_
_See code: [src/commands/help.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/help.ts)_

## `kipper new [LOCATION]`

Expand All @@ -145,7 +145,7 @@ OPTIONS
-d, --default Use the default settings for the new project. Skips the setup wizard.
```

_See code: [src/commands/new.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/new.ts)_
_See code: [src/commands/new.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/new.ts)_

## `kipper run [FILE]`

Expand Down Expand Up @@ -190,7 +190,7 @@ EXAMPLES
kipper run -t ts -o build/ -e utf8 -s "print('Hello, World!');" --warnings --log-timestamp
```

_See code: [src/commands/run.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/run.ts)_
_See code: [src/commands/run.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/run.ts)_

## `kipper version`

Expand All @@ -201,7 +201,7 @@ USAGE
$ kipper version
```

_See code: [src/commands/version.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/version.ts)_
_See code: [src/commands/version.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/version.ts)_
<!-- commandsstop -->

## Contributing to Kipper
Expand Down
2 changes: 1 addition & 1 deletion kipper/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kipper/cli",
"description": "The Kipper Command Line Interface (CLI).",
"version": "0.13.0-alpha.1",
"version": "0.13.0-alpha.2",
"author": "Luna-Klatzer @Luna-Klatzer",
"bin": {
"kipper": "./bin/run",
Expand Down
2 changes: 1 addition & 1 deletion kipper/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export * from "./output/compile";
// eslint-disable-next-line no-unused-vars
export const name = "@kipper/cli";
// eslint-disable-next-line no-unused-vars
export const version = "0.13.0-alpha.1";
export const version = "0.13.0-alpha.2";
// eslint-disable-next-line no-unused-vars
export const author = "Luna Klatzer";
// eslint-disable-next-line no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion kipper/config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kipper/config",
"description": "The config file support package adding support for kip-config.json/kipper-config.json 🦊",
"version": "0.13.0-alpha.1",
"version": "0.13.0-alpha.2",
"author": "Luna-Klatzer @Luna-Klatzer",
"dependencies": {
"is-plain-object": "5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion kipper/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export * from "./evaluated-kipper-config-file";
// eslint-disable-next-line no-unused-vars
export const name = "@kipper/config";
// eslint-disable-next-line no-unused-vars
export const version = "0.13.0-alpha.1";
export const version = "0.13.0-alpha.2";
// eslint-disable-next-line no-unused-vars
export const author = "Luna Klatzer";
// eslint-disable-next-line no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion kipper/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kipper/core",
"description": "The core implementation of the Kipper compiler 🦊",
"version": "0.13.0-alpha.1",
"version": "0.13.0-alpha.2",
"author": "Luna-Klatzer @Luna-Klatzer",
"dependencies": {
"antlr4ts": "^0.5.0-alpha.4",
Expand Down
2 changes: 1 addition & 1 deletion kipper/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export * as utils from "./tools";
// eslint-disable-next-line no-unused-vars
export const name = "@kipper/core";
// eslint-disable-next-line no-unused-vars
export const version = "0.13.0-alpha.1";
export const version = "0.13.0-alpha.2";
// eslint-disable-next-line no-unused-vars
export const author = "Luna Klatzer";
// eslint-disable-next-line no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion kipper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export * from "@kipper/target-ts";
// eslint-disable-next-line no-unused-vars
export const name = "kipper";
// eslint-disable-next-line no-unused-vars
export const version = "0.13.0-alpha.1";
export const version = "0.13.0-alpha.2";
// eslint-disable-next-line no-unused-vars
export const author = "Luna Klatzer";
// eslint-disable-next-line no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion kipper/target-js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kipper/target-js",
"description": "The JavaScript target for the Kipper compiler 🦊",
"version": "0.13.0-alpha.1",
"version": "0.13.0-alpha.2",
"author": "Luna-Klatzer @Luna-Klatzer",
"dependencies": {
"@kipper/core": "workspace:~",
Expand Down
7 changes: 5 additions & 2 deletions kipper/target-js/src/built-in-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export class JavaScriptTargetBuiltInGenerator extends KipperTargetBuiltInGenerat

return genJSFunction(
signature,
`{ if (${typeIdentifier}.acceptsVal(${valIdentifier})) { return ${valIdentifier} }` + `return null; }`,
`{ if ('acceptsVal' in ${typeIdentifier} && ${typeIdentifier}.acceptsVal(${valIdentifier})) { return ${valIdentifier} }` +
`try { if (${valIdentifier} instanceof ${typeIdentifier}) { return ${valIdentifier} } } catch (_) {}` +
`return null; }`,
);
}

Expand All @@ -148,7 +150,8 @@ export class JavaScriptTargetBuiltInGenerator extends KipperTargetBuiltInGenerat
return genJSFunction(
signature,
`{ const valType = ${valType};` +
`if (${typeIdentifier}.accepts(valType)) { return ${valIdentifier} }` +
`if ('acceptsVal' in ${typeIdentifier} && ${typeIdentifier}.acceptsVal(${valIdentifier})) { return ${valIdentifier} }` +
`try { if (${valIdentifier} instanceof ${typeIdentifier}) { return ${valIdentifier} } } catch (_) {}` +
`throw new ${typeErr}(\`Invalid force cast from '\${${valType}.name}' to '\${${typeIdentifier}.name}'.\`); }`,
);
}
Expand Down
2 changes: 1 addition & 1 deletion kipper/target-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export * from "./runtime/";
// eslint-disable-next-line no-unused-vars
export const name = "@kipper/target-js";
// eslint-disable-next-line no-unused-vars
export const version = "0.13.0-alpha.1";
export const version = "0.13.0-alpha.2";
// eslint-disable-next-line no-unused-vars
export const author = "Luna Klatzer";
// eslint-disable-next-line no-unused-vars
Expand Down
85 changes: 57 additions & 28 deletions kipper/target-js/src/runtime/create-kipper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
if (type.baseType === null) { return false; }
return this.isInHierarchyOfType(type.baseType);
}
accepts(obj) {
if (this === obj) return true;
return obj instanceof KipperType && (this.customComparer ? this.customComparer(this, obj) : true);
accepts(objT) {
if (this === objT) return true;
return objT instanceof KipperType && (this.customComparer ? this.customComparer(this, objT) : true);
}
acceptsVal(obj) {
return this.accepts(__tmpKip.typeOf(obj));
Expand All @@ -51,12 +51,12 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
constructor(name, fields, methods, genericArgs, baseType = null, customComparer = null) {
super(name, fields, methods, baseType, customComparer); this.genericArgs = genericArgs;
}
accepts(obj) {
if (this === obj) return true;
if (!(obj instanceof KipperGenericType) || this.genericArgs.length !== obj.genericArgs.length) return false;
const foreignGenericArgs = Object.entries(obj.genericArgs);
return this.name === obj.name &&
(this.customComparer ? this.customComparer(this, obj) : true) &&
accepts(objT) {
if (this === objT) return true;
if (!(objT instanceof KipperGenericType) || this.genericArgs.length !== objT.genericArgs.length) return false;
const foreignGenericArgs = Object.entries(objT.genericArgs);
return this.name === objT.name &&
(this.customComparer ? this.customComparer(this, objT) : true) &&
Object.entries(this.genericArgs).every((arg, i) => {
if (Array.isArray(arg)) {
if (!Array.isArray(foreignGenericArgs[i]) || arg.length !== foreignGenericArgs[i].length) { return false; }
Expand All @@ -67,6 +67,32 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
}
changeGenericTypeArguments(genericArgs) { return new KipperGenericType(this.name, this.fields, this.methods, genericArgs, this.baseType) }
};
class KipperInterfaceType extends KipperType {
constructor(name, fields, methods, baseType = null, customComparer = null) {
super(name, fields, methods, baseType, customComparer);
}
accepts(objT) {
if (this === objT) return true;
if (!(objT instanceof KipperInterfaceType)) return false;
return this.isSubsetOfOrEqual(objT) &&
(this.customComparer ? this.customComparer(this, objT) : true);
}
acceptsVal(obj) {
const objT = __tmpKip.typeOf(obj);
if (objT !== __tmpKip.builtIn.obj && !(obj instanceof Object)) return false;
return __tmpKip.matches(obj, this);
}
isSubsetOfOrEqual(objT) {
return this.fields.every((field) => {
const fieldInObjT = objT.fields.find((f) => f.name === field.name);
return fieldInObjT && field.type.accepts(fieldInObjT.type);
}) && this.methods.every((method) => {
const methodInObjT = objT.methods.find((m) => m.name === method.name);
return methodInObjT && method.returnType.accepts(methodInObjT.returnType) && method.parameters.length === methodInObjT.parameters.length &&
method.parameters.every((param, i) => param.type.accepts(methodInObjT.parameters[i].type));
});
}
}
const __type_any = new KipperType('any', undefined, undefined);
const __type_null = new KipperType('null', undefined, undefined, undefined, (a, b) => a.name === b.name);
const __type_undefined = new KipperType('undefined', undefined, undefined, undefined, (a, b) => a.name === b.name);
Expand All @@ -77,15 +103,15 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
const __type_Array = new KipperGenericType('Array', undefined, undefined, {T: __type_any}, undefined, (a, b) => a.name === b.name);
const __type_Func = new KipperGenericType('Func', undefined, undefined, {T: [], R: __type_any}, undefined, (a, b) => a.name === b.name);
__tmpKip.builtIn = {
any: __type_any,
null: __type_null,
undefined: __type_undefined,
str: __type_str,
num: __type_num,
bool: __type_bool,
obj: __type_obj,
Array: __type_Array,
Func: __type_Func,
any: __type_any,
null: __type_null,
undefined: __type_undefined,
str: __type_str,
num: __type_num,
bool: __type_bool,
obj: __type_obj,
Array: __type_Array,
Func: __type_Func,
};
__tmpKip.KipperError = KipperError;
__tmpKip.TypeError = (class KipperTypeError extends KipperError { constructor(msg) { super(msg); this.name = 'KipTypeError'; } });
Expand All @@ -96,29 +122,32 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
__tmpKip.Method = class KipperMethod { constructor(name, returnType, parameters) { this.name = name; this.returnType = returnType; this.parameters = parameters; } };
__tmpKip.Type = KipperType;
__tmpKip.assignTypeMeta = (value, typeMeta) => Object.assign(value, { __kipType: typeMeta });
__tmpKip.getTypeMeta = (value) => value.__kipType;
__tmpKip.newArrayT = (type) => __tmpKip.builtIn.Array.changeGenericTypeArguments({ T: type });
__tmpKip.newFuncT = (params, returnType) => __tmpKip.builtIn.Func.changeGenericTypeArguments({ T: params, R: returnType });
__tmpKip.newIntfT = (name, fields, methods, baseType = __tmpKip.builtIn.obj, customComparer = null) => new KipperInterfaceType(name, fields, methods, baseType, customComparer);
__tmpKip.typeOf = (value) => {
const prim = typeof value;
switch (prim) {
case 'undefined': return __kipper.builtIn.undefined;
case 'string': return __kipper.builtIn.str;
case 'number': return __kipper.builtIn.num;
case 'boolean': return __kipper.builtIn.bool;
case 'undefined': return __tmpKip.builtIn.undefined;
case 'string': return __tmpKip.builtIn.str;
case 'number': return __tmpKip.builtIn.num;
case 'boolean': return __tmpKip.builtIn.bool;
case 'function': {
return '__kipType' in value ? value.__kipType : __kipper.builtIn.Func;
return '__kipType' in value ? value.__kipType : __tmpKip.builtIn.Func;
}
case 'symbol':
case 'bigint':
case 'object': {
if (value === null) return __kipper.builtIn.null;
if (value === null) return __tmpKip.builtIn.null;
if (Array.isArray(value)) {
return '__kipType' in value ? value.__kipType : __kipper.builtIn.Array;
return '__kipType' in value ? value.__kipType : __tmpKip.builtIn.Array;
}
const prot = Object.getPrototypeOf(value);
if (prot && prot.constructor !== Object) {
return prot.constructor;
}
return __kipper.builtIn.obj;
return __tmpKip.builtIn.obj;
}
}
};
Expand All @@ -134,15 +163,15 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
return false;
}
const fieldValue = value[fieldName];
const isSameType = __kipper.typeOf(fieldValue) === field.type;
const isSameType = __tmpKip.typeOf(fieldValue) === field.type;
if (primTypes.includes(field.type.name) && !isSameType) {
return false;
}
if (genTypes.includes(fieldType.name)) {
throw new KipperNotImplementedError("Matches does not yet support the 'Array' and 'Func' types");
}
if (!primTypes.includes(fieldType.name)) {
if (!__kipper.matches(fieldValue, fieldType)) {
if (!__tmpKip.matches(fieldValue, fieldType)) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion kipper/target-js/src/runtime/runtime-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class RuntimeTypesGenerator {
"const ",
identifier,
" = ",
`new ${TargetJS.getBuiltInIdentifier("Type")}`,
TargetJS.getBuiltInIdentifier("newIntfT"),
"(",
`"${interfaceName}"`,
",",
Expand Down
2 changes: 1 addition & 1 deletion kipper/target-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kipper/target-ts",
"description": "The TypeScript target for the Kipper compiler 🦊",
"version": "0.13.0-alpha.1",
"version": "0.13.0-alpha.2",
"author": "Luna-Klatzer @Luna-Klatzer",
"dependencies": {
"@kipper/target-js": "workspace:~",
Expand Down
2 changes: 1 addition & 1 deletion kipper/target-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export * from "./tools";
// eslint-disable-next-line no-unused-vars
export const name = "@kipper/target-ts";
// eslint-disable-next-line no-unused-vars
export const version = "0.13.0-alpha.1";
export const version = "0.13.0-alpha.2";
// eslint-disable-next-line no-unused-vars
export const author = "Luna Klatzer";
// eslint-disable-next-line no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion kipper/web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kipper/web",
"description": "The standalone web-module for the Kipper compiler 🦊",
"version": "0.13.0-alpha.1",
"version": "0.13.0-alpha.2",
"author": "Luna-Klatzer @Luna-Klatzer",
"devDependencies": {
"@kipper/target-js": "workspace:~",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kipper",
"description": "The Kipper programming language and compiler 🦊",
"version": "0.13.0-alpha.1",
"version": "0.13.0-alpha.2",
"author": "Luna-Klatzer @Luna-Klatzer",
"dependencies": {
"@kipper/cli": "workspace:~",
Expand Down
Loading
Loading