From 7b0e1702b184a7a884146bf2b6e1424a12dd064d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 21:44:28 +0100 Subject: [PATCH 01/12] add cover comparison to workflow --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index deea1171..c8c1b4bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,3 +22,13 @@ jobs: - run: npm run test:build - run: npm run test:jest - run: npm run cover-all + - uses: actions/checkout@v2 + with: + ref: main + path: main-branch + run: | + cd main-branch + npm run cover-all + run: | + cd .. + npm run cover-all:compare -- --base main-branch/cover-all.json --compare cover-all.json From bf45d208d0b30fd9eda8d8084180c483e642396e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 21:47:39 +0100 Subject: [PATCH 02/12] fix yaml --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c8c1b4bb..a20512f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,9 +26,9 @@ jobs: with: ref: main path: main-branch - run: | - cd main-branch - npm run cover-all - run: | - cd .. - npm run cover-all:compare -- --base main-branch/cover-all.json --compare cover-all.json + - run: | + cd main-branch + npm run cover-all + - run: | + cd .. + npm run cover-all:compare -- --base main-branch/cover-all.json --compare cover-all.json From 4e56b69bcbf6d477e8e062f00f3ca911b63fa118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 21:54:32 +0100 Subject: [PATCH 03/12] remove some features from python --- src/languages/python/emit.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/languages/python/emit.ts b/src/languages/python/emit.ts index ac64220e..55f325a9 100644 --- a/src/languages/python/emit.ts +++ b/src/languages/python/emit.ts @@ -104,17 +104,17 @@ export class PythonEmitter extends PrecedenceVisitorEmitter { return prop === "object" ? Infinity : prop === "collection" && - (kind === "IndexCall" || kind === "RangeIndexCall") - ? Infinity - : kind === "ConditionalOp" - ? this.prec(parent) + (prop === "alternate" ? 0 : 1) - : kind === "Infix" - ? prop === "left" - ? this.prec(parent) + (parent.name === "**" ? 1 : 0) - : this.prec(parent) + (parent.name === "**" ? 0 : 1) - : kind === "Prefix" || kind === "Postfix" - ? this.prec(parent) - : -Infinity; + (kind === "IndexCall" || kind === "RangeIndexCall") + ? Infinity + : kind === "ConditionalOp" + ? this.prec(parent) + (prop === "alternate" ? 0 : 1) + : kind === "Infix" + ? prop === "left" + ? this.prec(parent) + (parent.name === "**" ? 1 : 0) + : this.prec(parent) + (parent.name === "**" ? 0 : 1) + : kind === "Prefix" || kind === "Postfix" + ? this.prec(parent) + : -Infinity; } visitNoParens(n: Node, spine: Spine, context: CompilationContext) { @@ -137,7 +137,7 @@ export class PythonEmitter extends PrecedenceVisitorEmitter { spine.isRoot || containsMultiNode(n.children) ? "\n" : ";", ); case "Import": - return [n.name, joinTrees(",", n.modules)]; + throw new Error(); case "While": return [`while`, $.condition, ":", multiNode($.body)]; case "ForEach": From 8881fcebc94dd3f543ec795644a36a8716bfcd6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 21:55:45 +0100 Subject: [PATCH 04/12] prettier --- src/languages/python/emit.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/languages/python/emit.ts b/src/languages/python/emit.ts index 55f325a9..4ebfb203 100644 --- a/src/languages/python/emit.ts +++ b/src/languages/python/emit.ts @@ -104,17 +104,17 @@ export class PythonEmitter extends PrecedenceVisitorEmitter { return prop === "object" ? Infinity : prop === "collection" && - (kind === "IndexCall" || kind === "RangeIndexCall") - ? Infinity - : kind === "ConditionalOp" - ? this.prec(parent) + (prop === "alternate" ? 0 : 1) - : kind === "Infix" - ? prop === "left" - ? this.prec(parent) + (parent.name === "**" ? 1 : 0) - : this.prec(parent) + (parent.name === "**" ? 0 : 1) - : kind === "Prefix" || kind === "Postfix" - ? this.prec(parent) - : -Infinity; + (kind === "IndexCall" || kind === "RangeIndexCall") + ? Infinity + : kind === "ConditionalOp" + ? this.prec(parent) + (prop === "alternate" ? 0 : 1) + : kind === "Infix" + ? prop === "left" + ? this.prec(parent) + (parent.name === "**" ? 1 : 0) + : this.prec(parent) + (parent.name === "**" ? 0 : 1) + : kind === "Prefix" || kind === "Postfix" + ? this.prec(parent) + : -Infinity; } visitNoParens(n: Node, spine: Spine, context: CompilationContext) { From 295b97e5172d790c87d7ec6754fc685245263144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 21:57:38 +0100 Subject: [PATCH 05/12] remove cd --- .github/workflows/test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a20512f3..3388786c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,4 @@ jobs: - run: | cd main-branch npm run cover-all - - run: | - cd .. - npm run cover-all:compare -- --base main-branch/cover-all.json --compare cover-all.json + - run: npm run cover-all:compare -- --base main-branch/cover-all.json --compare cover-all.json From 6c011359e7dbf2e54ed09c04a7fa3d5befba8639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 21:58:42 +0100 Subject: [PATCH 06/12] lint --- src/languages/python/emit.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/languages/python/emit.ts b/src/languages/python/emit.ts index 4ebfb203..690b60b3 100644 --- a/src/languages/python/emit.ts +++ b/src/languages/python/emit.ts @@ -10,7 +10,6 @@ import { emitIntLiteral, emitTextFactory, getIfChain, - joinTrees, } from "../../common/emit"; import { isInt, isText, id, type Node, type If } from "../../IR"; import { type CompilationContext } from "../../common/compile"; From d73f8ea8cffb2a0b9e7d90efc319bd133e59bdcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 22:01:07 +0100 Subject: [PATCH 07/12] put py stuff back, it fails unit obviously --- src/languages/python/emit.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/languages/python/emit.ts b/src/languages/python/emit.ts index 690b60b3..ac64220e 100644 --- a/src/languages/python/emit.ts +++ b/src/languages/python/emit.ts @@ -10,6 +10,7 @@ import { emitIntLiteral, emitTextFactory, getIfChain, + joinTrees, } from "../../common/emit"; import { isInt, isText, id, type Node, type If } from "../../IR"; import { type CompilationContext } from "../../common/compile"; @@ -136,7 +137,7 @@ export class PythonEmitter extends PrecedenceVisitorEmitter { spine.isRoot || containsMultiNode(n.children) ? "\n" : ";", ); case "Import": - throw new Error(); + return [n.name, joinTrees(",", n.modules)]; case "While": return [`while`, $.condition, ":", multiNode($.body)]; case "ForEach": From 312d1c500ae364304e44f003ccc2fa2f3a8288b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 22:03:44 +0100 Subject: [PATCH 08/12] modify cover script to see if comparison works --- src/cover/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cover/index.ts b/src/cover/index.ts index 20d2a148..a420e7de 100644 --- a/src/cover/index.ts +++ b/src/cover/index.ts @@ -127,10 +127,10 @@ function printTable(name: string, x: Table) { v2 === true ? "✔️" : v2 === false - ? "❌" - : v2 === undefined - ? "" - : v2, + ? "❌" + : v2 === undefined + ? "" + : v2, ), })), ]).replaceAll("❌ ", "❌"), // no table generating library I tried was able to align ❌ correctly @@ -153,7 +153,7 @@ const features: CoverTableRecipe = { builtin: (lang) => lang.stmt(nextBuiltin(integerType(0, 0))), discard: (lang) => lang.expr(), bigint: (lang) => lang.stmt(int(10n ** 40n)), - if: (lang) => ifStatement(lang.expr(booleanType), lang.stmt(), lang.stmt()), + if: (lang) => lang.stmt(int(10n ** 40n)), for: (lang) => forRangeCommon( [ From f275b55a97e2c9a206115312318b92ca553412d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 22:05:40 +0100 Subject: [PATCH 09/12] lint --- src/cover/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cover/index.ts b/src/cover/index.ts index a420e7de..1b4fca15 100644 --- a/src/cover/index.ts +++ b/src/cover/index.ts @@ -127,10 +127,10 @@ function printTable(name: string, x: Table) { v2 === true ? "✔️" : v2 === false - ? "❌" - : v2 === undefined - ? "" - : v2, + ? "❌" + : v2 === undefined + ? "" + : v2, ), })), ]).replaceAll("❌ ", "❌"), // no table generating library I tried was able to align ❌ correctly From aabfd864eca69c13c21343c1fae2c5fa84c14476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 22:07:37 +0100 Subject: [PATCH 10/12] lint --- src/cover/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cover/index.ts b/src/cover/index.ts index 1b4fca15..56a5b5e5 100644 --- a/src/cover/index.ts +++ b/src/cover/index.ts @@ -10,7 +10,6 @@ import { int, id, func, - ifStatement, whileLoop, forArgv, conditional, From 5645350e5841805ed2b2ea1e3d8e7c0b973d8e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 22:19:25 +0100 Subject: [PATCH 11/12] is this stuck? --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99350d22..f6cf0ffe 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ npm install . --location=global This will set up the `polygolf` command to point to the CLI script. -Polygolf CLI supports the following options: +Polygolf CLI supports the following options:: - `--input`, `-i`: path to the input program - `--lang`, `-l`: target language name or its extension, if omitted, targets all supported languages From b1162b792d44140a3ce1e422345469909dd8aa1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= Date: Mon, 11 Mar 2024 22:27:33 +0100 Subject: [PATCH 12/12] revert --- README.md | 2 +- src/cover/index.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f6cf0ffe..99350d22 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ npm install . --location=global This will set up the `polygolf` command to point to the CLI script. -Polygolf CLI supports the following options:: +Polygolf CLI supports the following options: - `--input`, `-i`: path to the input program - `--lang`, `-l`: target language name or its extension, if omitted, targets all supported languages diff --git a/src/cover/index.ts b/src/cover/index.ts index 56a5b5e5..20d2a148 100644 --- a/src/cover/index.ts +++ b/src/cover/index.ts @@ -10,6 +10,7 @@ import { int, id, func, + ifStatement, whileLoop, forArgv, conditional, @@ -152,7 +153,7 @@ const features: CoverTableRecipe = { builtin: (lang) => lang.stmt(nextBuiltin(integerType(0, 0))), discard: (lang) => lang.expr(), bigint: (lang) => lang.stmt(int(10n ** 40n)), - if: (lang) => lang.stmt(int(10n ** 40n)), + if: (lang) => ifStatement(lang.expr(booleanType), lang.stmt(), lang.stmt()), for: (lang) => forRangeCommon( [