From 572938bd6ae3e2f2e235bfb8c08280444e86176d Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 03:17:57 +0300 Subject: [PATCH 01/12] fix: Bytes --- eo-phi-normalizer/grammar/EO/Phi/Syntax.cf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf index be918021..36ce7fb2 100644 --- a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf @@ -4,7 +4,7 @@ -- -- This is a non-ambiguous grammar for φ-programs. -token Bytes ({"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ({"-"} ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}) ; +token Bytes ({"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] {"-"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ({"-"} ["0123456789ABCDEF"] ["0123456789ABCDEF"])+) ; token Function upper (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; token LabelId lower (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; token AlphaIndex ({"α0"} | {"α"} (digit - ["0"]) (digit)* ) ; From 0ddcdd98fb262900f042d2c274144a678470bde1 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 03:18:26 +0300 Subject: [PATCH 02/12] upd: parser and lexer --- .../src/Language/EO/Phi/Syntax/Abs.hs | 2 +- .../src/Language/EO/Phi/Syntax/Doc.txt | 174 +++++++++--------- .../src/Language/EO/Phi/Syntax/Lex.x | 4 +- .../src/Language/EO/Phi/Syntax/Par.y | 2 +- .../src/Language/EO/Phi/Syntax/Print.hs | 2 +- 5 files changed, 92 insertions(+), 92 deletions(-) diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs index 04444019..ae634d48 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs @@ -1,4 +1,4 @@ --- File generated by the BNF Converter (bnfc 2.9.6). +-- File generated by the BNF Converter (bnfc 2.9.5). {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt index 6b3ef07d..5bdd30af 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt @@ -1,87 +1,87 @@ -The Language Syntax -BNF Converter - - -%Process by txt2tags to generate html or latex - - - -This document was automatically generated by the //BNF-Converter//. It was generated together with the lexer, the parser, and the abstract syntax module, which guarantees that the document matches with the implementation of the language (provided no hand-hacking has taken place). - -==The lexical structure of Syntax== - -===Literals=== - - - - - -Bytes literals are recognized by the regular expression -`````{"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ('-' ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}````` - -Function literals are recognized by the regular expression -`````upper (char - [" - !'(),-.:;?[]{|}⟦⟧"])*````` - -LabelId literals are recognized by the regular expression -`````lower (char - [" - !'(),-.:;?[]{|}⟦⟧"])*````` - -AlphaIndex literals are recognized by the regular expression -`````{"α0"} | 'α' (digit - '0') digit*````` - - -===Reserved words and symbols=== -The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. - -The reserved words used in Syntax are the following: - | ``Δ`` | ``Φ`` | ``λ`` | ``ν`` - | ``ξ`` | ``ρ`` | ``σ`` | ``φ`` - -The symbols used in Syntax are the following: - | { | } | ⟦ | ⟧ - | ( | ) | . | ⊥ - | ↦ | ∅ | ⤍ | , - -===Comments=== -There are no single-line comments in the grammar.There are no multiple-line comments in the grammar. - -==The syntactic structure of Syntax== -Non-terminals are enclosed between < and >. -The symbols -> (production), **|** (union) -and **eps** (empty rule) belong to the BNF notation. -All other symbols are terminals. - - | //Program// | -> | ``{`` //[Binding]// ``}`` - | //Object// | -> | ``⟦`` //[Binding]// ``⟧`` - | | **|** | //Object// ``(`` //[Binding]// ``)`` - | | **|** | //Object// ``.`` //Attribute// - | | **|** | ``Φ`` ``.`` //Attribute// - | | **|** | ``ξ`` ``.`` //Attribute// - | | **|** | ``⊥`` - | //Binding// | -> | //Attribute// ``↦`` //Object// - | | **|** | //Attribute// ``↦`` ``∅`` - | | **|** | ``Δ`` ``⤍`` //Bytes// - | | **|** | ``λ`` ``⤍`` //Function// - | //[Binding]// | -> | **eps** - | | **|** | //Binding// - | | **|** | //Binding// ``,`` //[Binding]// - | //Attribute// | -> | ``φ`` - | | **|** | ``ρ`` - | | **|** | ``σ`` - | | **|** | ``ν`` - | | **|** | //LabelId// - | | **|** | //AlphaIndex// - | //PeeledObject// | -> | //ObjectHead// //[ObjectAction]// - | //ObjectHead// | -> | ``{`` //[Binding]// ``}`` - | | **|** | ``Φ`` - | | **|** | ``ξ`` - | | **|** | ``⊥`` - | //ObjectAction// | -> | ``{`` //[Binding]// ``}`` - | | **|** | ``.`` //Attribute// - | //[ObjectAction]// | -> | **eps** - | | **|** | //ObjectAction// //[ObjectAction]// - - - -%% File generated by the BNF Converter (bnfc 2.9.6). +The Language Syntax +BNF Converter + + +%Process by txt2tags to generate html or latex + + + +This document was automatically generated by the //BNF-Converter//. It was generated together with the lexer, the parser, and the abstract syntax module, which guarantees that the document matches with the implementation of the language (provided no hand-hacking has taken place). + +==The lexical structure of Syntax== + +===Literals=== + + + + + +Bytes literals are recognized by the regular expression +`````{"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] '-' | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ('-' ["0123456789ABCDEF"] ["0123456789ABCDEF"])+````` + +Function literals are recognized by the regular expression +`````upper (char - [" + !'(),-.:;?[]{|}⟦⟧"])*````` + +LabelId literals are recognized by the regular expression +`````lower (char - [" + !'(),-.:;?[]{|}⟦⟧"])*````` + +AlphaIndex literals are recognized by the regular expression +`````{"α0"} | 'α' (digit - '0') digit*````` + + +===Reserved words and symbols=== +The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. + +The reserved words used in Syntax are the following: + | ``Δ`` | ``Φ`` | ``λ`` | ``ν`` + | ``ξ`` | ``ρ`` | ``σ`` | ``φ`` + +The symbols used in Syntax are the following: + | { | } | ⟦ | ⟧ + | ( | ) | . | ⊥ + | ↦ | ∅ | ⤍ | , + +===Comments=== +There are no single-line comments in the grammar.There are no multiple-line comments in the grammar. + +==The syntactic structure of Syntax== +Non-terminals are enclosed between < and >. +The symbols -> (production), **|** (union) +and **eps** (empty rule) belong to the BNF notation. +All other symbols are terminals. + + | //Program// | -> | ``{`` //[Binding]// ``}`` + | //Object// | -> | ``⟦`` //[Binding]// ``⟧`` + | | **|** | //Object// ``(`` //[Binding]// ``)`` + | | **|** | //Object// ``.`` //Attribute// + | | **|** | ``Φ`` ``.`` //Attribute// + | | **|** | ``ξ`` ``.`` //Attribute// + | | **|** | ``⊥`` + | //Binding// | -> | //Attribute// ``↦`` //Object// + | | **|** | //Attribute// ``↦`` ``∅`` + | | **|** | ``Δ`` ``⤍`` //Bytes// + | | **|** | ``λ`` ``⤍`` //Function// + | //[Binding]// | -> | **eps** + | | **|** | //Binding// + | | **|** | //Binding// ``,`` //[Binding]// + | //Attribute// | -> | ``φ`` + | | **|** | ``ρ`` + | | **|** | ``σ`` + | | **|** | ``ν`` + | | **|** | //LabelId// + | | **|** | //AlphaIndex// + | //PeeledObject// | -> | //ObjectHead// //[ObjectAction]// + | //ObjectHead// | -> | ``{`` //[Binding]// ``}`` + | | **|** | ``Φ`` + | | **|** | ``ξ`` + | | **|** | ``⊥`` + | //ObjectAction// | -> | ``{`` //[Binding]// ``}`` + | | **|** | ``.`` //Attribute// + | //[ObjectAction]// | -> | **eps** + | | **|** | //ObjectAction// //[ObjectAction]// + + + +%% File generated by the BNF Converter (bnfc 2.9.5). diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x index f71d6594..c59d9fa5 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x @@ -1,4 +1,4 @@ --- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.6). +-- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.5). -- Lexer definition for use with Alex 3 { @@ -40,7 +40,7 @@ $white+ ; { tok (eitherResIdent TV) } -- token Bytes -\- \- | [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F](\- [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F]) * (\- \-) +\- \- | [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F]\- | [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F](\- [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F]) + { tok (eitherResIdent T_Bytes) } -- token Function diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y index 1fba4210..3964497f 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y @@ -1,4 +1,4 @@ --- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.6). +-- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.5). -- Parser definition for use with Happy { diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs index a12f4ab9..62bc1129 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs @@ -1,4 +1,4 @@ --- File generated by the BNF Converter (bnfc 2.9.6). +-- File generated by the BNF Converter (bnfc 2.9.5). {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} From ba2cad0b5ce89fb8021113be8cd2db3900cab6f1 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 28 Dec 2023 17:52:39 +0300 Subject: [PATCH 03/12] #3: simple integration test --- .github/workflows/itest.yml | 20 +++++++++++++++++++ .gitignore | 4 ++++ pipeline.sh | 40 +++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 .github/workflows/itest.yml create mode 100755 pipeline.sh diff --git a/.github/workflows/itest.yml b/.github/workflows/itest.yml new file mode 100644 index 00000000..b0512b35 --- /dev/null +++ b/.github/workflows/itest.yml @@ -0,0 +1,20 @@ +name: itest +on: + push: + branches: master + pull_request: + branches: master +jobs: + itest: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 16 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 20 + - run: npm install -g eolang + - run: ./pipeline.sh \ No newline at end of file diff --git a/.gitignore b/.gitignore index fc587c5e..8a188c2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +.eoc +before.txt +after.txt +app.eo *.bak eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs diff --git a/pipeline.sh b/pipeline.sh new file mode 100755 index 00000000..0b026e6e --- /dev/null +++ b/pipeline.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -x +set -e + +EO=0.34.2 + +cat > app.eo < app + QQ.io.stdout > @ + "Hello, world!\n" +EOT + +eoc "--parser=${EO}" clean +eoc "--parser=${EO}" link +eoc "--parser=${EO}" --alone dataize app > before.txt + +eoc "--parser=${EO}" phi + +# Now, you modify/normalize this file: +# .eoc/phi/app.phi + +eoc "--parser=${EO}" unphi + +cp .eoc/unphi/app.xmir .eoc/2-optimize/app.xmir + +eoc "--parser=${EO}" print + +cp .eoc/print/app.eo app.eo + +eoc "--parser=${EO}" clean + +eoc "--parser=${EO}" link +eoc "--parser=${EO}" --alone dataize app > after.txt + +if [ "$(cat before.txt)" == "$(cat after.txt)" ]; then + echo 'SUCCESS' +else + echo 'FAILURE' + exit 1 +fi \ No newline at end of file From 78adce241e4a184888ab47f5af69243321fb93d1 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 28 Dec 2023 17:57:40 +0300 Subject: [PATCH 04/12] #3: typo --- pipeline.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/pipeline.sh b/pipeline.sh index 0b026e6e..39474f40 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -28,7 +28,6 @@ eoc "--parser=${EO}" print cp .eoc/print/app.eo app.eo eoc "--parser=${EO}" clean - eoc "--parser=${EO}" link eoc "--parser=${EO}" --alone dataize app > after.txt From 7206f790d041b11720dc01e159188e59f8dc01aa Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 02:49:35 +0300 Subject: [PATCH 05/12] refactor: pipeline script --- pipeline.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pipeline.sh b/pipeline.sh index 39474f40..a0697e85 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -1,8 +1,10 @@ -#!/bin/bash -set -x -set -e +mkdir -p pipeline +cd pipeline + +shopt -s expand_aliases EO=0.34.2 +alias eo="eoc --parser=${EO}" cat > app.eo < app @@ -10,26 +12,26 @@ cat > app.eo < before.txt +eo clean +eo link +eo --alone dataize app > before.txt -eoc "--parser=${EO}" phi +eo phi # Now, you modify/normalize this file: # .eoc/phi/app.phi -eoc "--parser=${EO}" unphi +eo unphi cp .eoc/unphi/app.xmir .eoc/2-optimize/app.xmir -eoc "--parser=${EO}" print +eo print cp .eoc/print/app.eo app.eo -eoc "--parser=${EO}" clean -eoc "--parser=${EO}" link -eoc "--parser=${EO}" --alone dataize app > after.txt +eo clean +eo link +eo --alone dataize app > after.txt if [ "$(cat before.txt)" == "$(cat after.txt)" ]; then echo 'SUCCESS' From 0b68687be5f3477cbe2983e1114547e6afef728b Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 03:09:38 +0300 Subject: [PATCH 06/12] feat: run normalizer --- pipeline.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pipeline.sh b/pipeline.sh index a0697e85..02f9c942 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -19,7 +19,11 @@ eo --alone dataize app > before.txt eo phi # Now, you modify/normalize this file: -# .eoc/phi/app.phi +IO=".eoc/phi/app.phi" +I=".eoc/phi/app.bk.phi" +mv "$IO" "$I" +stack run normalize-phi < "$I" > "$IO" \ + || echo 'Normalizer failed' && exit 1 eo unphi From 8b4bbd4552b3957b6294bd1bf8bdc34fed64aec0 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 03:19:45 +0300 Subject: [PATCH 07/12] rm: test action --- .github/workflows/itest.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .github/workflows/itest.yml diff --git a/.github/workflows/itest.yml b/.github/workflows/itest.yml deleted file mode 100644 index b0512b35..00000000 --- a/.github/workflows/itest.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: itest -on: - push: - branches: master - pull_request: - branches: master -jobs: - itest: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 16 - - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: 20 - - run: npm install -g eolang - - run: ./pipeline.sh \ No newline at end of file From 10bcc1ceb2abebae95e4aa0e620df10adddeaa79 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 03:19:54 +0300 Subject: [PATCH 08/12] upd: action --- .github/workflows/ghc.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index b53026bd..28c4018b 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -27,10 +27,24 @@ jobs: uses: actions/checkout@v4 - name: 🧰 Setup Stack - uses: freckle/stack-action@v4 + # FIXME use freckle/stack-action@v4 when https://github.com/freckle/stack-action/pull/31 is merged + uses: deemp/stack-action with: fast: ${{ github.ref_name != 'master' }} + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: 21 + + - run: npm install -g eolang@0.15.1 + + - run: ./pipeline.sh + haddock: needs: [build] if: ${{ github.ref_name == 'master' }} From 8747b44c5cdf949e9c5f10b4e13b9c49c068652b Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 03:26:10 +0300 Subject: [PATCH 09/12] fix: ref --- .github/workflows/ghc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index 28c4018b..2fa57511 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -28,7 +28,7 @@ jobs: - name: 🧰 Setup Stack # FIXME use freckle/stack-action@v4 when https://github.com/freckle/stack-action/pull/31 is merged - uses: deemp/stack-action + uses: deemp/stack-action@main with: fast: ${{ github.ref_name != 'master' }} From c5659367d9cbf9e7f78060cd3f8899fd90be5c92 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 03:35:07 +0300 Subject: [PATCH 10/12] add: script that runs pipeline --- flake.lock | 38 ++++++++++++++++++++++++++++---- flake.nix | 64 ++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 91 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index 9669d63d..bb01383d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,28 @@ { "nodes": { + "eoc": { + "flake": false, + "locked": { + "lastModified": 1704732261, + "narHash": "sha256-UOwwOpbVQjVraZebqQbq4BPitCKpwcL6s3ywjAfGCaw=", + "owner": "deemp", + "repo": "eoc", + "rev": "c338c36db124212efbb85f31d12e04e04bcde450", + "type": "github" + }, + "original": { + "owner": "deemp", + "repo": "eoc", + "type": "github" + } + }, "flakes": { "locked": { - "lastModified": 1703248027, - "narHash": "sha256-kq2J/wLaUL3KY/OwgZEAZ7/QZ5alrol9ERBWqxJshiA=", + "lastModified": 1704589266, + "narHash": "sha256-iuqS9ieLQYcTIKT7GHrqBf89yNU6rdYp+ge08ww5zC0=", "owner": "deemp", "repo": "flakes", - "rev": "8b4c8ae507d591ad41e239e70a9c2d226b7eaa45", + "rev": "dcb6e49b7c7df2dd381d204a9316572d7087c373", "type": "github" }, "original": { @@ -15,9 +31,23 @@ "type": "github" } }, + "maven-wrapper-jar": { + "flake": false, + "locked": { + "narHash": "sha256-O6tlCRB5YmX0T0F240jGhiln1jwkKO8XgyCvtHSq40A=", + "type": "file", + "url": "https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + }, + "original": { + "type": "file", + "url": "https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + } + }, "root": { "inputs": { - "flakes": "flakes" + "eoc": "eoc", + "flakes": "flakes", + "maven-wrapper-jar": "maven-wrapper-jar" } } }, diff --git a/flake.nix b/flake.nix index c4b3fa91..c63ea575 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,24 @@ { - inputs.flakes.url = "github:deemp/flakes"; + inputs = { + flakes.url = "github:deemp/flakes"; + eoc = { + url = "github:deemp/eoc"; + flake = false; + }; + # should be synchronized with + # https://github.com/objectionary/eoc/blob/116286a11aa538705c0f2b794abbdbcc6dec33ef/mvnw/.mvn/wrapper/maven-wrapper.properties#L18 + maven-wrapper-jar = { + flake = false; + url = "https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"; + }; + }; outputs = inputs: inputs.flakes.makeFlake { inputs = { inherit (inputs.flakes.all) - haskell-tools codium drv-tools devshell - flakes-tools nixpkgs formatter workflows lima; + haskell-tools drv-tools devshell + flakes-tools nixpkgs formatter + slimlock; + inherit (inputs) eoc maven-wrapper-jar; }; perSystem = { inputs, system }: let @@ -14,8 +28,9 @@ # --- Imports --- pkgs = inputs.nixpkgs.legacyPackages.${system}; + inherit (pkgs) lib; inherit (inputs.devshell.lib.${system}) mkCommands mkRunCommands mkShell; - inherit (inputs.drv-tools.lib.${system}) withAttrs withMan withDescription mkShellApp man; + inherit (inputs.drv-tools.lib.${system}) mkShellApps; inherit (inputs.flakes-tools.lib.${system}) mkFlakesTools; inherit (inputs.haskell-tools.lib.${system}) toolsGHC; @@ -69,7 +84,7 @@ packages = ps: [ ps.${packageName} ]; }) hls cabal fourmolu justStaticExecutable - ghcid haskellPackages hpack stack; + ghcid ghc haskellPackages hpack stack; # --- Tools --- @@ -80,6 +95,7 @@ fourmolu cabal stack + pkgs.gh # `cabal` already has a `ghc` on its `PATH`, # so you may remove `ghc` from this list. # Then, you can access `ghc` like `cabal exec -- ghc --version`. @@ -93,7 +109,30 @@ # --- Packages --- - packages = { + packages = mkShellApps { + eoc = pkgs.buildNpmPackage rec { + name = ""; + version = "0.15.1"; + src = inputs.eoc; + npmDepsHash = "sha256-j6lfte6RhxRY5cRHcrtIHfZDe0lP1ovEukgHbHsGPb0="; + npmInstallFlags = [ "--omit=dev" ]; + dontNpmBuild = true; + + postPatch = + let path = "mvnw/.mvn/wrapper/maven-wrapper.jar"; in + '' + cp ${inputs.maven-wrapper-jar} ${path} + chmod +x ${path} + ''; + meta = with pkgs.lib; { + description = "EO compiler"; + homepage = "https://github.com/objectionary/eoc"; + license = licenses.mit; + }; + }; + + # + # --- Haskell package --- # This is a static executable with given runtime dependencies. @@ -104,6 +143,17 @@ }; "${packageName}" = haskellPackages."${packageName}"; + + pipeline = { + runtimeInputs = [ stack pkgs.jdk21 packages.eoc pkgs.maven ]; + text = '' + JAVA_HOME="${pkgs.jdk21.home}" + export JAVA_HOME + ${builtins.readFile ./pipeline.sh} + ''; + description = "Run pipeline"; + excludeShellChecks = [ "SC2139" ]; + }; }; # --- Devshells --- @@ -115,7 +165,7 @@ bash.extra = "export LANG=C.utf8"; commands = mkCommands "tools" tools - ++ mkRunCommands "packages" { inherit (packages) default; } + ++ mkRunCommands "packages" { inherit (packages) default pipeline; } ; }; }; From f1325b0520775e5bafece4fa31393dc0ae0a88e6 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 04:05:57 +0300 Subject: [PATCH 11/12] fix: error message --- pipeline.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pipeline.sh b/pipeline.sh index 02f9c942..ba25d7be 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -23,7 +23,16 @@ IO=".eoc/phi/app.phi" I=".eoc/phi/app.bk.phi" mv "$IO" "$I" stack run normalize-phi < "$I" > "$IO" \ - || echo 'Normalizer failed' && exit 1 + || printf "\n\nNormalizer failed" \ + && printf "\n\n* EO Expression\n\n" \ + && cat app.eo \ + && printf "\n\n* Phi Expression\n\n" \ + && cat "$I" \ + && printf "\n\n* Error\n\n" \ + && cat "$IO" \ + && exit 1 + +printf "Normalizer succeeded" eo unphi From a187a84020f8763fa2e5e57e1a98b3ce3f488398 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 10 Jan 2024 04:21:59 +0300 Subject: [PATCH 12/12] fix: normalizer logs --- pipeline.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/pipeline.sh b/pipeline.sh index ba25d7be..04ba4239 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -23,16 +23,24 @@ IO=".eoc/phi/app.phi" I=".eoc/phi/app.bk.phi" mv "$IO" "$I" stack run normalize-phi < "$I" > "$IO" \ - || printf "\n\nNormalizer failed" \ - && printf "\n\n* EO Expression\n\n" \ - && cat app.eo \ - && printf "\n\n* Phi Expression\n\n" \ - && cat "$I" \ - && printf "\n\n* Error\n\n" \ - && cat "$IO" \ - && exit 1 - -printf "Normalizer succeeded" + || { + printf "\n\nNormalizer failed" + printf "\n\n* EO expression:\n\n" + cat app.eo + printf "\n\n* Phi expression:\n\n" + cat "$I" + printf "\n\n* Error:\n\n" + cat "$IO" + exit 1 + } + +printf "\n\nNormalizer succeeded!\n\n" +printf "\n\n* Phi expression:\n\n" +cat "$I" +printf "\n\n* Normalized Phi expression:\n\n" +cat "$IO" +printf "\n\n* Diff:\n\n" +diff "$I" "$IO" eo unphi