From df8216879819038823108b0a737487728ba7fd60 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 6 Feb 2024 16:50:11 +0300 Subject: [PATCH 01/70] feat: add eo submodule --- .gitmodules | 3 +++ eo | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 eo diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..e439e41c6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "eo"] + path = eo + url = https://github.com/objectionary/eo diff --git a/eo b/eo new file mode 160000 index 000000000..638c61150 --- /dev/null +++ b/eo @@ -0,0 +1 @@ +Subproject commit 638c61150a7e433804d5debe9ecafc7d67194eb8 From ac800c547a49c74bac651052e26764948cb00f82 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 6 Feb 2024 18:30:12 +0300 Subject: [PATCH 02/70] fix: set eo to 0.34.1 --- eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo b/eo index 638c61150..4ced5a8e7 160000 --- a/eo +++ b/eo @@ -1 +1 @@ -Subproject commit 638c61150a7e433804d5debe9ecafc7d67194eb8 +Subproject commit 4ced5a8e79394abbbc009dfab5a9fa43c4fcca74 From 7ccb80f4aeded4fd4d793af8447d0262afd19bc7 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 6 Feb 2024 18:36:31 +0300 Subject: [PATCH 03/70] fix: clone submodules too --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4c95cca6b..d17a6b18d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ attribute access (`t.a`) that amounts to _dynamic dispatch_. Clone this repo. ```sh -git clone https://github.com/objectionary/normalizer.git +git clone --recurse-submodules https://github.com/objectionary/normalizer.git cd normalizer ``` @@ -185,7 +185,7 @@ The project is developed using the [Stack tool](https://docs.haskellstack.org/en We recommend using `stack` for quick local development and testing. Clone this project and run `stack build`. ```sh -git clone https://github.com/objectionary/normalizer.git +git clone --recurse-submodules https://github.com/objectionary/normalizer.git cd normalizer stack build ``` From 0dd53445ff6a216b6788a2ce1304062d56941fdf Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 7 Feb 2024 01:16:40 +0300 Subject: [PATCH 04/70] feat: add script to transform the original eo tests --- hie.yaml | 9 ++ pipeline/config.yaml | 19 +++ scripts/transform-eo-tests/app/Main.hs | 128 ++++++++++++++++++ scripts/transform-eo-tests/package.yaml | 45 ++++++ .../transform-eo-tests.cabal | 36 +++++ stack.yaml | 1 + 6 files changed, 238 insertions(+) create mode 100644 pipeline/config.yaml create mode 100644 scripts/transform-eo-tests/app/Main.hs create mode 100644 scripts/transform-eo-tests/package.yaml create mode 100644 scripts/transform-eo-tests/transform-eo-tests.cabal diff --git a/hie.yaml b/hie.yaml index debcb134c..4c1aa3ee6 100644 --- a/hie.yaml +++ b/hie.yaml @@ -6,5 +6,14 @@ cradle: - path: "eo-phi-normalizer/app/Main.hs" component: "eo-phi-normalizer:exe:normalize-phi" + - path: "eo-phi-normalizer/app/Paths_eo_phi_normalizer.hs" + component: "eo-phi-normalizer:exe:normalize-phi" + - path: "eo-phi-normalizer/test" component: "eo-phi-normalizer:test:eo-phi-normalizer-test" + + - path: "scripts/transform-eo-tests/app/Main.hs" + component: "transform-eo-tests:exe:transform-eo-tests" + + - path: "scripts/transform-eo-tests/app/Paths_transform_eo_tests.hs" + component: "transform-eo-tests:exe:transform-eo-tests" diff --git a/pipeline/config.yaml b/pipeline/config.yaml new file mode 100644 index 000000000..0acb22968 --- /dev/null +++ b/pipeline/config.yaml @@ -0,0 +1,19 @@ +yamlDirectory: pipeline/yaml +sets: +- source: eo/eo-runtime/src/test/eo/org/eolang/as-phi-tests.eo + yaml: pipeline/yaml/as-phi-tests.yaml + destination: pipeline/eolang/as-phi-tests.eo + programs: + - prints-itself + - prints-itself-to-console +- source: eo/eo-runtime/src/test/eo/org/eolang/bool-tests.eo + yaml: pipeline/yaml/bool-tests.yaml + destination: pipeline/eolang/bool-tests.eo + programs: + - compares-two-bools + - compares-two-different-types + - forks-on-condition + - iterates-over-simple-counter + - compares-bool-to-bytes + - compares-bool-to-string + - compares-bool-to-bytes-reverse diff --git a/scripts/transform-eo-tests/app/Main.hs b/scripts/transform-eo-tests/app/Main.hs new file mode 100644 index 000000000..c29596167 --- /dev/null +++ b/scripts/transform-eo-tests/app/Main.hs @@ -0,0 +1,128 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE InstanceSigs #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedRecordDot #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ViewPatterns #-} + +module Main (main) where + +import Control.Monad +import Data.Function ((&)) +import Data.Functor ((<&>)) +import Data.List.Extra (split) +import Data.String (IsString (..)) +import Data.Text qualified as T +import Data.Yaml (FromJSON, ToJSON (..), Value (String), decodeFileThrow, encodeFile) +import Data.Yaml.Aeson (FromJSON (..), withText) +import GHC.Generics (Generic) +import Main.Utf8 (withUtf8) +import System.Directory.Extra (createDirectoryIfMissing, removeFile) +import System.FilePath.Posix + +main :: IO () +main = withUtf8 do + let testDir = "pipeline" + config <- decodeFileThrow @_ @TestConfig (testDir "config.yaml") + createDirectoryIfMissing True config.yamlDirectory + forM_ config.sets $ \set -> do + test@Test{source, meta, license} <- parseTest set.source + let programs = filter (\x -> x.name `elem` set.programs) test.programs + testContent = TestContent{..} + + -- write yaml + let target = set.yaml + targetTmp = target <.> ".tmp" + createDirectoryIfMissing True (takeDirectory target) + writeFile target license + encodeFile targetTmp testContent + readFile targetTmp >>= appendFile target + removeFile targetTmp + + -- write eo + createDirectoryIfMissing True (takeDirectory set.destination) + writeFile set.destination (license <> meta) + forM_ programs (\x -> appendFile set.destination x.text) + +data TestSet = TestSet + { source :: FilePath + , yaml :: FilePath + , destination :: FilePath + , programs :: [String] + } + deriving (Show, Generic, FromJSON) + +data TestConfig = TestConfig + { yamlDirectory :: FilePath + , sets :: [TestSet] + } + deriving (Show, Generic, FromJSON) + +data Pos = Pos + { file :: FilePath + , line :: Int + } + deriving (Show) + +instance ToJSON Pos where + toJSON :: Pos -> Value + toJSON Pos{..} = String (fromString (file <> ":" <> show line)) + +instance FromJSON Pos where + parseJSON = withText "Pos" $ \(T.unpack -> x) -> do + let ts = split (== ':') x + guard (length ts == 2) + let [file, line'] = ts + guard (not . null $ file) + guard (not . null $ line') + let line = read line' + pure Pos{..} + +data Program = Program + { source :: Pos + , name :: String + , text :: String + } + deriving (Show, Generic, ToJSON, FromJSON) + +data Test = Test + { source :: String + , license :: String + , meta :: String + , programs :: [Program] + } + deriving (Show, Generic, ToJSON, FromJSON) + +data TestContent = TestContent + { source :: FilePath + , meta :: String + , programs :: [Program] + } + deriving (Show, Generic, ToJSON, FromJSON) + +parseProgramsRaw :: ([(Int, [String])], (Int, [[Char]]), Int) -> [[Char]] -> [(Int, String)] +parseProgramsRaw (programs', (programStart, program), curLine) (line'@(x : _) : xs) + | (program /= [] && head program == "" || null program) && (x == '[' || x == '#') = parseProgramsRaw ((programStart, program) : programs', (curLine, [line']), curLine + 1) xs + | otherwise = parseProgramsRaw (programs', (programStart, line' : program), curLine + 1) xs +parseProgramsRaw (programs', (programStart, program), curLine) ("" : xs) = parseProgramsRaw (programs', (programStart, "" : program), curLine + 1) xs +parseProgramsRaw (programs', program, _) [] = (unlines <$>) <$> drop 1 (reverse ((reverse <$>) <$> (program : programs'))) + +parseTest' :: FilePath -> [String] -> Test +parseTest' source eoCode = + let + (license, k') = span (\case '#' : _ -> True; "" -> True; _ -> False) eoCode + (meta, k'') = span (\case '+' : _ -> True; "" -> True; _ -> False) k' + programsStart = length license + length meta + 1 + programsRaw = parseProgramsRaw ([], (programsStart, []), programsStart) k'' + programs = programsRaw <&> (\(line, text) -> Program{source = Pos{file = source, ..}, name = text & dropWhile (/= '[') & drop 5 & takeWhile (/= '\n'), ..}) + in + Test{license = unlines license, meta = unlines meta, ..} + +parseTest :: FilePath -> IO Test +parseTest path = readFile path <&> (parseTest' path . lines) diff --git a/scripts/transform-eo-tests/package.yaml b/scripts/transform-eo-tests/package.yaml new file mode 100644 index 000000000..8adb7eac3 --- /dev/null +++ b/scripts/transform-eo-tests/package.yaml @@ -0,0 +1,45 @@ +name: transform-eo-tests +version: 0.1.0.0 +github: "value/transform-eo-tests" +license: BSD3 + +# Metadata used when publishing your package +# synopsis: Short description of your package +# category: value + +# To avoid duplicated efforts in documentation and dealing with the +# complications of embedding Haddock markup inside cabal files, it is +# common to point users to the README.md file. +description: Please see the README on GitHub at + +default-extensions: + - ImportQualifiedPost + +dependencies: + - base >= 4.7 && < 5 + - yaml + - extra + - filepath + - mtl + - with-utf8 + - text + +ghc-options: + - -Wall + - -Wcompat + - -Widentities + - -Wincomplete-record-updates + - -Wincomplete-uni-patterns + - -Wmissing-export-lists + - -Wmissing-home-modules + - -Wpartial-fields + - -Wredundant-constraints + +executables: + transform-eo-tests: + main: Main.hs + source-dirs: app + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N diff --git a/scripts/transform-eo-tests/transform-eo-tests.cabal b/scripts/transform-eo-tests/transform-eo-tests.cabal new file mode 100644 index 000000000..b2cb46137 --- /dev/null +++ b/scripts/transform-eo-tests/transform-eo-tests.cabal @@ -0,0 +1,36 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.36.0. +-- +-- see: https://github.com/sol/hpack + +name: transform-eo-tests +version: 0.1.0.0 +description: Please see the README on GitHub at +homepage: https://github.com/value/transform-eo-tests#readme +bug-reports: https://github.com/value/transform-eo-tests/issues +license: BSD3 +build-type: Simple + +source-repository head + type: git + location: https://github.com/value/transform-eo-tests + +executable transform-eo-tests + main-is: Main.hs + other-modules: + Paths_transform_eo_tests + hs-source-dirs: + app + default-extensions: + ImportQualifiedPost + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N + build-depends: + base >=4.7 && <5 + , extra + , filepath + , mtl + , text + , with-utf8 + , yaml + default-language: Haskell2010 diff --git a/stack.yaml b/stack.yaml index 4516c0fc7..047c8e01f 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,3 +1,4 @@ resolver: nightly-2023-12-14 packages: - eo-phi-normalizer +- scripts/transform-eo-tests From db7e156054b768fbb291f507e9d38603e1545ee0 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 7 Feb 2024 01:16:53 +0300 Subject: [PATCH 05/70] refactor: remove old pipeline files --- pipeline/programs/1/app.eo | 3 - pipeline/programs/1/before.txt | 1 - pipeline/programs/2/app.eo | 176 --------------------------------- pipeline/programs/2/before.txt | 0 4 files changed, 180 deletions(-) delete mode 100644 pipeline/programs/1/app.eo delete mode 100644 pipeline/programs/1/before.txt delete mode 100644 pipeline/programs/2/app.eo delete mode 100644 pipeline/programs/2/before.txt diff --git a/pipeline/programs/1/app.eo b/pipeline/programs/1/app.eo deleted file mode 100644 index 9e43124e1..000000000 --- a/pipeline/programs/1/app.eo +++ /dev/null @@ -1,3 +0,0 @@ -[args] > app - QQ.io.stdout > @ - "Hello, world!\n" diff --git a/pipeline/programs/1/before.txt b/pipeline/programs/1/before.txt deleted file mode 100644 index af5626b4a..000000000 --- a/pipeline/programs/1/before.txt +++ /dev/null @@ -1 +0,0 @@ -Hello, world! diff --git a/pipeline/programs/2/app.eo b/pipeline/programs/2/app.eo deleted file mode 100644 index 81ab1538e..000000000 --- a/pipeline/programs/2/app.eo +++ /dev/null @@ -1,176 +0,0 @@ -+alias org.eolang.io.stdout -+alias org.eolang.txt.sprintf -+alias org.eolang.txt.sscanf -+alias org.eolang.collections.list - -[n1 n2 length] > graphedge - -[node edges] > nodeInEdges - reduce. > @ - list - edges - FALSE - [accum current] - or. > @ - accum - or. - eq. - ^.node - current.n1 - eq. - ^.node - current.n2 - -[node nArray] > nodeInArray - reduce. > @ - list - nArray - FALSE - [accum current] - or. > @ - accum - eq. - ^.node - current - -[edges] > nodes - reduce. > @ - list - edges - * - [accum current] - not. > addN1! - nodeInArray - current.n1 - accum - not. > addN2! - nodeInArray - current.n2 - accum - if. > @ - and. - addN1 - addN2 - with. - with. - accum - current.n1 - current.n2 - if. - and. - addN1 - addN2.not - with. - accum - current.n1 - if. - and. - addN1.not - addN2 - with. - accum - current.n2 - accum - -[s1 s2] > join - s1.as-bytes > x1 - s2.as-bytes > x2 - x1.concat x2 > x3 - x3.as-string > @ - -[args...] > app - [] > graph! - [i] > getEdges - if. > @ - (i.plus 2).lt - ^.^.args.length - with. - ^.getEdges - i.plus 3 - graphedge - (sscanf "%d" (^.^.args.at i)).at 0 - (sscanf "%d" (^.^.args.at (i.plus 1))).at 0 - (sscanf "%d" (^.^.args.at (i.plus 2))).at 0 - * - if. > @ - ^.args.length.lt 3 - * - getEdges 0 - - nodes > graphNodes! - graph - - [mi id] > getMin - if. > @ - not. - lt. - id - ^.graph.length - mi - if. - lt. - (^.graph.at id).length - (^.graph.at mi).length - ^.getMin id (id.plus 1) - ^.getMin mi (id.plus 1) - - graph.at (getMin 0 0) > firstEdge - [step] > findEdges - [min id] > findNext - if. > @ - not. - lt. - id - ^.^.graph.length - min - seq - nodeInEdges > n1InStep! - (^.^.graph.at id).n1 - ^.step - nodeInEdges > n2InStep! - (^.^.graph.at id).n2 - ^.step - if. - and. - or. - and. - n1InStep - n2InStep.not - and. - n1InStep.not - n2InStep - or. - min.eq -1 - lt. - (^.^.graph.at id).length - (^.^.graph.at min).length - ^.findNext id (id.plus 1) - ^.findNext min (id.plus 1) - findNext -1 0 > res - if. > @ - eq. - -1 - res - step - ^.findEdges - with. - step - (^.graph.at res) - findEdges (* firstEdge) > ans! - [i] > output - if. > @ - i.eq - ans.length - "" - join - sprintf - "(%d %d - %d) " - (^.ans.at i).n1 - (^.ans.at i).n2 - (^.ans.at i).length - ^.output (i.plus 1) - join "MST: " (output 0) > ret - stdout > @ - sprintf - "%s \n" - ret diff --git a/pipeline/programs/2/before.txt b/pipeline/programs/2/before.txt deleted file mode 100644 index e69de29bb..000000000 From 8558eb3196424e4a7de74e2cbe75cf5e55275a90 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 08:52:38 +0300 Subject: [PATCH 06/70] fix: directory name in test config --- pipeline/config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipeline/config.yaml b/pipeline/config.yaml index 0acb22968..33d6b3e60 100644 --- a/pipeline/config.yaml +++ b/pipeline/config.yaml @@ -2,13 +2,13 @@ yamlDirectory: pipeline/yaml sets: - source: eo/eo-runtime/src/test/eo/org/eolang/as-phi-tests.eo yaml: pipeline/yaml/as-phi-tests.yaml - destination: pipeline/eolang/as-phi-tests.eo + destination: pipeline/eo/as-phi-tests.eo programs: - prints-itself - prints-itself-to-console - source: eo/eo-runtime/src/test/eo/org/eolang/bool-tests.eo yaml: pipeline/yaml/bool-tests.yaml - destination: pipeline/eolang/bool-tests.eo + destination: pipeline/eo/bool-tests.eo programs: - compares-two-bools - compares-two-different-types From e958b4829b05bd2cc42f524023a637bfc757e226 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 08:54:08 +0300 Subject: [PATCH 07/70] refactor: pipeline script --- pipeline.sh | 134 ++++++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 61 deletions(-) diff --git a/pipeline.sh b/pipeline.sh index 7dfabed09..8f5f195af 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -1,103 +1,115 @@ set -euo pipefail -ROOT_DIR="$PWD" - -mkdir -p ".pipeline/$PROGRAM" -cd ".pipeline/$PROGRAM" +stack run transform-eo-tests shopt -s expand_aliases - -EO="0.34.3" +EO="0.34.1" alias eo="eoc --parser=${EO}" -cp "$ROOT_DIR"/pipeline/programs/"$PROGRAM"/app.eo . +cd pipeline/eo +eoc clean +eoc phi +cd .. + +mkdir -p phi +cp eo/.eoc/phi/*.phi phi + +cd phi +# TODO #100:15min run normalizer +# normalizer should create phi-normalized +cd .. + +# TODO #100:15min run unphi +# cd phi-normalized +# eo unphi +# cd .. +# mkdir -p eo-normalized +# copy normalized files to eo-normalized -# Without normalizer +# TODO #100:15min run tests +# cd eo-normalized +# eo test -eo clean -eo link -eo --alone dataize app > before.txt -cp before.txt "$ROOT_DIR"/pipeline/programs/"$PROGRAM"/before.txt -# With normalizer -eo phi +# TODO #100:15min remove old code +# eo phi -IO=".eoc/phi/app.phi" -I=".eoc/phi/app.bk.phi" -mv "$IO" "$I" +# IO=".eoc/phi/app.phi" +# I=".eoc/phi/app.bk.phi" +# mv "$IO" "$I" -stack run normalize-phi < "$I" > "$IO" \ - || { - cat < "$IO" \ +# || { +# cat < after.txt +# eo clean +# eo link +# eo --alone dataize app > after.txt -# Check dataization with and without the normalizer -# produces the same results +# # Check dataization with and without the normalizer +# # produces the same results -if [ "$(cat before.txt)" == "$(cat after.txt)" ]; then - echo 'SUCCESS' -else - echo 'FAILURE' - exit 1 -fi +# if [ "$(cat before.txt)" == "$(cat after.txt)" ]; then +# echo 'SUCCESS' +# else +# echo 'FAILURE' +# exit 1 +# fi From 6319b78eb3c42171dc6837e93dd459198f140f1d Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 08:56:00 +0300 Subject: [PATCH 08/70] refactor: action --- .github/workflows/ghc.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index 4ca298037..cbde96029 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -42,12 +42,14 @@ jobs: pipeline: name: "Run pipeline" - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - program: [1] - + os: + - ubuntu-latest + - macos-latest + - windows-latest steps: - name: 📥 Checkout repository uses: actions/checkout@v4 @@ -71,8 +73,6 @@ jobs: - name: Run pipeline run: ./pipeline.sh - env: - PROGRAM: ${{ matrix.program }} haddock: needs: [build] From 26127b684dd39ab9e0714b26f427b98b2bf18b35 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 08:56:13 +0300 Subject: [PATCH 09/70] fix: gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f75f14925..4b0dca3ba 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,5 @@ __pycache__ *.fdb_latexmk *.fls *.log +pipeline/* +!pipeline/config.yaml From 99c517356e54e2a2bd5213d15e21978a472e228b Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 11:36:31 +0300 Subject: [PATCH 10/70] fix: incomplete pattern matches warning --- scripts/transform-eo-tests/app/Main.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/transform-eo-tests/app/Main.hs b/scripts/transform-eo-tests/app/Main.hs index c29596167..1a769c34a 100644 --- a/scripts/transform-eo-tests/app/Main.hs +++ b/scripts/transform-eo-tests/app/Main.hs @@ -16,7 +16,6 @@ module Main (main) where import Control.Monad import Data.Function ((&)) import Data.Functor ((<&>)) -import Data.List.Extra (split) import Data.String (IsString (..)) import Data.Text qualified as T import Data.Yaml (FromJSON, ToJSON (..), Value (String), decodeFileThrow, encodeFile) @@ -25,6 +24,7 @@ import GHC.Generics (Generic) import Main.Utf8 (withUtf8) import System.Directory.Extra (createDirectoryIfMissing, removeFile) import System.FilePath.Posix +import Text.Read (readMaybe) main :: IO () main = withUtf8 do @@ -76,13 +76,11 @@ instance ToJSON Pos where instance FromJSON Pos where parseJSON = withText "Pos" $ \(T.unpack -> x) -> do - let ts = split (== ':') x - guard (length ts == 2) - let [file, line'] = ts + let (file, rs) = span (/= ':') x guard (not . null $ file) - guard (not . null $ line') - let line = read line' - pure Pos{..} + guard (length rs > 1) + let line' = readMaybe (drop 1 rs) + maybe (fail $ x <> " is not a number") (\line -> pure Pos{..}) line' data Program = Program { source :: Pos From 5e013498aa5d518d3906105719d65b887f840104 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 11:51:10 +0300 Subject: [PATCH 11/70] fix: enable submodules --- .github/workflows/ghc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index cbde96029..fefca253c 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -53,6 +53,8 @@ jobs: steps: - name: 📥 Checkout repository uses: actions/checkout@v4 + with: + submodules: true - name: 🧰 Setup Stack uses: freckle/stack-action@v5 From 81e92041eb1d4adedee6b53bcda26f92c6587a33 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 19:16:41 +0300 Subject: [PATCH 12/70] feat: add eolang as a dev dependency --- .gitignore | 1 + package-lock.json | 622 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 + 3 files changed, 628 insertions(+) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 4b0dca3ba..4a68deaa7 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ __pycache__ *.log pipeline/* !pipeline/config.yaml +node_modules diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..dfd24d3de --- /dev/null +++ b/package-lock.json @@ -0,0 +1,622 @@ +{ + "name": "normalizer", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "eolang": "^0.15.1" + } + }, + "node_modules/@types/concat-stream": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.1.tgz", + "integrity": "sha512-eHE4cQPoj6ngxBZMvVf6Hw7Mh4jMW4U9lpGmS5GBPB9RYxlFg+CHaVN7ErNY4W9XfLIEn20b4VDYaIrbq0q4uA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/form-data": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz", + "integrity": "sha512-8BSvG1kGm83cyJITQMZSulnl6QV8jqAGreJsc5tPu1Jq0vTSOiY/k24Wx82JRpWwZSqrala6sd5rWi6aNXvqcw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "10.17.60", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", + "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==", + "dev": true + }, + "node_modules/@types/qs": { + "version": "6.9.11", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.11.tgz", + "integrity": "sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ==", + "dev": true + }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/call-bind": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.6.tgz", + "integrity": "sha512-Mj50FLHtlsoVfRfnHaZvyrooHcrlceNZdL/QBvJJVd9Ta55qCQK0gs4ss2oZDeV9zFCs6ewzYgVE5yfVmfFpVg==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.3", + "set-function-length": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", + "dev": true + }, + "node_modules/colors": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", + "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", + "dev": true, + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "dev": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "node_modules/define-data-property": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.2.tgz", + "integrity": "sha512-SRtsSqsDbgpJBbW3pABMCOt6rQyeM8s8RiyeSN8jYG8sYmt/kGJejbydttUsnDs1tadr19tvhT4ShwMyoqAm4g==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.2", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/eolang": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/eolang/-/eolang-0.15.1.tgz", + "integrity": "sha512-zU7sZFH3Bv3VTKrg+/uLl13KNI1zFDfJNU8KkBddKdbeK4WRxrtg8FK/ZEIJ6OST6UE4w1ftaiotuYk6KRwBwg==", + "dev": true, + "os": [ + "darwin", + "linux", + "win32" + ], + "dependencies": { + "colors": "1.4.0", + "commander": "11.1.0", + "fast-xml-parser": "4.3.2", + "node": "21.2.0", + "relative": "3.0.2", + "sync-request": "6.1.0", + "xmlhttprequest": "1.8.0" + }, + "bin": { + "eoc": "src/eoc.js" + }, + "engines": { + "node": ">6.0", + "npm": ">8.0" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/fast-xml-parser": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.2.tgz", + "integrity": "sha512-rmrXUXwbJedoXkStenj1kkljNF7ugn5ZjR9FJcwmCfcCbtOMDghPajbc+Tck6vE6F5XsDmx+Pr2le9fw8+pXBg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-port": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz", + "integrity": "sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-basic": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/http-basic/-/http-basic-8.1.3.tgz", + "integrity": "sha512-/EcDMwJZh3mABI2NhGfHOGOeOZITqfkEO4p/xK+l3NpyncIHUQBoMvCSF/b5GqvKtySC2srL/GGG3+EtlqlmCw==", + "dev": true, + "dependencies": { + "caseless": "^0.12.0", + "concat-stream": "^1.6.2", + "http-response-object": "^3.0.1", + "parse-cache-control": "^1.0.1" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/http-response-object": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-3.0.2.tgz", + "integrity": "sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA==", + "dev": true, + "dependencies": { + "@types/node": "^10.0.3" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "node_modules/isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==", + "dev": true, + "dependencies": { + "isarray": "1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node": { + "version": "21.2.0", + "resolved": "https://registry.npmjs.org/node/-/node-21.2.0.tgz", + "integrity": "sha512-oiHX7SXGdO1wyg0/lZ1ZMy1iS7GgumsT5Ptt5BOye1WniC8OJ2TtYRuWfqNoKrUlYzI4+Bv1+NH5eDgxuThU2A==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "node-bin-setup": "^1.0.0" + }, + "bin": { + "node": "bin/node" + }, + "engines": { + "npm": ">=5.0.0" + } + }, + "node_modules/node-bin-setup": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/node-bin-setup/-/node-bin-setup-1.1.3.tgz", + "integrity": "sha512-opgw9iSCAzT2+6wJOETCpeRYAQxSopqQ2z+N6BXwIMsQQ7Zj5M8MaafQY8JMlolRR6R1UXg2WmhKp0p9lSOivg==", + "dev": true + }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/parse-cache-control": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", + "integrity": "sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg==", + "dev": true + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "node_modules/promise": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.3.0.tgz", + "integrity": "sha512-rZPNPKTOYVNEEKFaq1HqTgOwZD+4/YHS5ukLzQCypkj+OkYx7iv0mA91lJlpPPZ8vMau3IIGj5Qlwrx+8iiSmg==", + "dev": true, + "dependencies": { + "asap": "~2.0.6" + } + }, + "node_modules/qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", + "dev": true, + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/relative": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/relative/-/relative-3.0.2.tgz", + "integrity": "sha512-Q5W2qeYtY9GbiR8z1yHNZ1DGhyjb4AnLEjt8iE6XfcC1QIu+FAtj3HQaO0wH28H1mX6cqNLvAqWhP402dxJGyA==", + "dev": true, + "dependencies": { + "isobject": "^2.0.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/set-function-length": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", + "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", + "dev": true, + "dependencies": { + "define-data-property": "^1.1.2", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/side-channel": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", + "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==", + "dev": true + }, + "node_modules/sync-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-6.1.0.tgz", + "integrity": "sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw==", + "dev": true, + "dependencies": { + "http-response-object": "^3.0.1", + "sync-rpc": "^1.2.1", + "then-request": "^6.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/sync-rpc": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.6.tgz", + "integrity": "sha512-J8jTXuZzRlvU7HemDgHi3pGnh/rkoqR/OZSjhTyyZrEkkYQbk7Z33AXp37mkPfPpfdOuj7Ex3H/TJM1z48uPQw==", + "dev": true, + "dependencies": { + "get-port": "^3.1.0" + } + }, + "node_modules/then-request": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/then-request/-/then-request-6.0.2.tgz", + "integrity": "sha512-3ZBiG7JvP3wbDzA9iNY5zJQcHL4jn/0BWtXIkagfz7QgOL/LqjCEOBQuJNZfu0XYnv5JhKh+cDxCPM4ILrqruA==", + "dev": true, + "dependencies": { + "@types/concat-stream": "^1.6.0", + "@types/form-data": "0.0.33", + "@types/node": "^8.0.0", + "@types/qs": "^6.2.31", + "caseless": "~0.12.0", + "concat-stream": "^1.6.0", + "form-data": "^2.2.0", + "http-basic": "^8.1.1", + "http-response-object": "^3.0.1", + "promise": "^8.0.0", + "qs": "^6.4.0" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/then-request/node_modules/@types/node": { + "version": "8.10.66", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.66.tgz", + "integrity": "sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw==", + "dev": true + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "dev": true + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + } + }, + "devDependencies": { + "eoc": "^0.15.1" + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..9415d9f91 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "eolang": "^0.15.1" + } +} From 819a488d07b13b87bb4ca41effb66afc689f561c Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 19:20:43 +0300 Subject: [PATCH 13/70] feat: enable eo phi --- pipeline.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pipeline.sh b/pipeline.sh index 8f5f195af..f1ad7e70b 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -1,14 +1,16 @@ set -euo pipefail -stack run transform-eo-tests - shopt -s expand_aliases EO="0.34.1" -alias eo="eoc --parser=${EO}" +alias eo="npx eoc --parser=${EO}" + +# generate EO test files +stack run transform-eo-tests +# convert EO to PHI cd pipeline/eo -eoc clean -eoc phi +eo clean +eo phi cd .. mkdir -p phi From 8d540f1794a70da5c0028b33e68b577056321912 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 8 Feb 2024 19:21:13 +0300 Subject: [PATCH 14/70] refactor: install eo from local node config --- .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 fefca253c..ecc4a8d14 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -71,7 +71,7 @@ jobs: java-version: 21 - name: Install EO - run: npm install -g eolang@0.15.1 + run: npm i - name: Run pipeline run: ./pipeline.sh From b78ed11fe68f3df28fb9fca1f394ab9d77b7162a Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 12:24:37 +0300 Subject: [PATCH 15/70] feat: add `single` option that prints a single normalized program --- eo-phi-normalizer/app/Main.hs | 36 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs index df4cef5ac..415c0891e 100644 --- a/eo-phi-normalizer/app/Main.hs +++ b/eo-phi-normalizer/app/Main.hs @@ -7,13 +7,13 @@ module Main where -import Control.Monad (when) +import Control.Monad (unless, when) import Data.Foldable (forM_) import Data.List (nub) import Language.EO.Phi (Object (Formation), Program (Program), defaultMain, parseProgram, printTree) import Language.EO.Phi.Rules.Common (Context (..), applyRules, applyRulesChain) -import Language.EO.Phi.Rules.Yaml +import Language.EO.Phi.Rules.Yaml (RuleSet (rules, title), convertRule, parseRuleSetFromFile) import Options.Generic import System.IO (IOMode (WriteMode), hClose, hPutStr, hPutStrLn, openFile, stdout) @@ -21,6 +21,7 @@ data CLINamedParams = CLINamedParams { chain :: Bool , rulesYaml :: Maybe String , outPath :: Maybe String + , single :: Bool } deriving (Generic, Show, ParseRecord, Read, ParseField) @@ -30,6 +31,7 @@ instance ParseFields CLINamedParams where <$> parseFields (Just "Print out steps of reduction") (Just "chain") (Just 'c') Nothing <*> parseFields (Just "Path to the Yaml file with custom rules") (Just "rules-yaml") Nothing Nothing <*> parseFields (Just "Output file path (defaults to stdout)") (Just "output") (Just 'o') Nothing + <*> parseFields (Just "Print a single normlized expression") (Just "single") (Just 's') Nothing data CLIOptions = CLIOptions CLINamedParams (Maybe FilePath) deriving (Generic, Show, ParseRecord) @@ -45,7 +47,7 @@ main = do let logStr = hPutStr handle let logStrLn = hPutStrLn handle ruleSet <- parseRuleSetFromFile path - logStrLn ruleSet.title + unless single $ logStrLn ruleSet.title src <- maybe getContents readFile inPath let progOrError = parseProgram src case progOrError of @@ -56,18 +58,22 @@ main = do | otherwise = pure <$> applyRules (Context (convertRule <$> ruleSet.rules)) (Formation bindings) uniqueResults = nub results totalResults = length uniqueResults - logStrLn "Input:" - logStrLn (printTree input) - logStrLn "====================================================" - forM_ (zip [1 ..] uniqueResults) $ \(i, steps) -> do - logStrLn $ - "Result " <> show i <> " out of " <> show totalResults <> ":" - let n = length steps - forM_ (zip [1 ..] steps) $ \(k, step) -> do - Control.Monad.when chain $ - logStr ("[ " <> show k <> " / " <> show n <> " ]") - logStrLn (printTree step) - logStrLn "----------------------------------------------------" + when (totalResults == 0) $ error "Could not normalize the program" + if single + then logStrLn (printTree (head uniqueResults)) + else do + logStrLn "Input:" + logStrLn (printTree input) + logStrLn "====================================================" + forM_ (zip [1 ..] uniqueResults) $ \(i, steps) -> do + logStrLn $ + "Result " <> show i <> " out of " <> show totalResults <> ":" + let n = length steps + forM_ (zip [1 ..] steps) $ \(k, step) -> do + when chain $ + logStr ("[ " <> show k <> " / " <> show n <> " ]") + logStrLn (printTree step) + logStrLn "----------------------------------------------------" hClose handle -- TODO #48:15m still need to consider `chain` (should rewrite/change defaultMain to mainWithOptions) Nothing -> defaultMain From e1f63e3874a2241c6cfbae5f1efe621b960b3d89 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 14:42:24 +0300 Subject: [PATCH 16/70] refactor: pipeline script --- pipeline.sh | 134 ++++++++++++++-------------------------------------- 1 file changed, 36 insertions(+), 98 deletions(-) diff --git a/pipeline.sh b/pipeline.sh index f1ad7e70b..57579c7b6 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -1,117 +1,55 @@ set -euo pipefail +if ! [ -d node_modules ]; then npm i; fi + shopt -s expand_aliases EO="0.34.1" alias eo="npx eoc --parser=${EO}" -# generate EO test files +printf "\nGenerate EO test files\n\n" + stack run transform-eo-tests -# convert EO to PHI +printf "\nConvert EO to PHI\n\n" + +mkdir -p phi cd pipeline/eo eo clean eo phi +cp .eoc/phi/*.phi ../phi cd .. -mkdir -p phi -cp eo/.eoc/phi/*.phi phi +printf "\nNormalize PHI\n\n" +mkdir -p phi-normalized cd phi -# TODO #100:15min run normalizer -# normalizer should create phi-normalized +for f in $(ls); do + stack run -- \ + -s \ + --rules-yaml \ + ../../eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \ + "$f" \ + > "../phi-normalized/$f" +done cd .. -# TODO #100:15min run unphi -# cd phi-normalized -# eo unphi -# cd .. -# mkdir -p eo-normalized -# copy normalized files to eo-normalized - -# TODO #100:15min run tests -# cd eo-normalized -# eo test - - - -# TODO #100:15min remove old code -# eo phi - -# IO=".eoc/phi/app.phi" -# I=".eoc/phi/app.bk.phi" -# mv "$IO" "$I" - -# stack run normalize-phi < "$I" > "$IO" \ -# || { -# cat < after.txt - -# # Check dataization with and without the normalizer -# # produces the same results +cd phi-normalized +cp -r ../eo/.eoc . +eo unphi +cp .eoc/unphi/*.xmir ".eoc/2-optimize" +cd .. -# if [ "$(cat before.txt)" == "$(cat after.txt)" ]; then -# echo 'SUCCESS' -# else -# echo 'FAILURE' -# exit 1 -# fi +printf "\nTest EO\n\n" + +mkdir -p eo-normalized +cd eo-normalized +cp ../phi-normalized/.eoc/print/*.eo . +for f in $(ls *.eo); do + if ! [ -s "${f}" ]; then + rm $f + fi +done +eo test +cd .. From 26d1d55501c040a7f6600cac69cd3c67d74170bb Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 14:53:57 +0300 Subject: [PATCH 17/70] fix: directory --- .github/workflows/ghc.yml | 4 +--- pipeline.sh | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index ecc4a8d14..a09abcd1b 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -59,6 +59,7 @@ jobs: - name: 🧰 Setup Stack uses: freckle/stack-action@v5 with: + test: false stack-build-arguments: --${{ github.ref_name != 'master' && 'fast' || '' }} --pedantic - uses: actions/setup-node@v4 @@ -70,9 +71,6 @@ jobs: distribution: "zulu" java-version: 21 - - name: Install EO - run: npm i - - name: Run pipeline run: ./pipeline.sh diff --git a/pipeline.sh b/pipeline.sh index 57579c7b6..be5970b38 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -10,10 +10,12 @@ printf "\nGenerate EO test files\n\n" stack run transform-eo-tests +cd pipeline + printf "\nConvert EO to PHI\n\n" mkdir -p phi -cd pipeline/eo +cd eo eo clean eo phi cp .eoc/phi/*.phi ../phi From 53ce6966b4df5e138a4ce22214c6c697720ea0c1 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 14:54:10 +0300 Subject: [PATCH 18/70] fix: print --- pipeline.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/pipeline.sh b/pipeline.sh index be5970b38..9ea1e84ba 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -41,6 +41,7 @@ cd phi-normalized cp -r ../eo/.eoc . eo unphi cp .eoc/unphi/*.xmir ".eoc/2-optimize" +eo print cd .. printf "\nTest EO\n\n" From 65b74e15386bfaced9183f986f76ca5374e8d849 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 16:11:25 +0300 Subject: [PATCH 19/70] feat: test without normalization --- pipeline.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pipeline.sh b/pipeline.sh index 9ea1e84ba..4278559ac 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -21,6 +21,26 @@ eo phi cp .eoc/phi/*.phi ../phi cd .. + +printf "\nConvert PHI to EO without normalization\n\n" + +mkdir -p eo-not-normalized +cd phi +cp -r ../eo/.eoc . +eo unphi +cp .eoc/unphi/*.xmir ".eoc/2-optimize" +eo print +cp .eoc/print/*.eo ../eo-not-normalized +cd .. + + +printf "\nTest EO without normalization\n\n" + +cd eo-not-normalized +eo test +cd .. + + printf "\nNormalize PHI\n\n" mkdir -p phi-normalized From 9e82c030e38400f4562136642509f11a8091733a Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 16:12:15 +0300 Subject: [PATCH 20/70] feat: clean pipeline directory before a run --- pipeline.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pipeline.sh b/pipeline.sh index 4278559ac..0964afd54 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -6,6 +6,11 @@ shopt -s expand_aliases EO="0.34.1" alias eo="npx eoc --parser=${EO}" +printf "\nClean the pipeline directory\n\n" + +rm -r pipeline/*/ + + printf "\nGenerate EO test files\n\n" stack run transform-eo-tests From 20711f43cecbad747dbbfbad4e72bb1fed76cab3 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 16:12:48 +0300 Subject: [PATCH 21/70] fix: don't remove empty files --- pipeline.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pipeline.sh b/pipeline.sh index 0964afd54..1f9566b32 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -74,10 +74,5 @@ printf "\nTest EO\n\n" mkdir -p eo-normalized cd eo-normalized cp ../phi-normalized/.eoc/print/*.eo . -for f in $(ls *.eo); do - if ! [ -s "${f}" ]; then - rm $f - fi -done eo test cd .. From b25a9788c858ef8bdcdbd9851c166a60498edfc1 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 16:13:49 +0300 Subject: [PATCH 22/70] feat: add one more print --- pipeline.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pipeline.sh b/pipeline.sh index 1f9566b32..58fc04c66 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -15,6 +15,9 @@ printf "\nGenerate EO test files\n\n" stack run transform-eo-tests + +printf "\nEnter the pipeline directory\n\n" + cd pipeline printf "\nConvert EO to PHI\n\n" From ef7b8ba3a5f62d243505a65286a0674644f8363b Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 16:14:01 +0300 Subject: [PATCH 23/70] refactor: formatting --- pipeline.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pipeline.sh b/pipeline.sh index 58fc04c66..6761cd766 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -20,6 +20,7 @@ printf "\nEnter the pipeline directory\n\n" cd pipeline + printf "\nConvert EO to PHI\n\n" mkdir -p phi @@ -63,6 +64,7 @@ for f in $(ls); do done cd .. + printf "\nConvert normalized PHI to EO\n\n" cd phi-normalized @@ -72,6 +74,7 @@ cp .eoc/unphi/*.xmir ".eoc/2-optimize" eo print cd .. + printf "\nTest EO\n\n" mkdir -p eo-normalized From 9c17919227be96afd4ad1dec4a4b8b63bb606130 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 16:14:23 +0300 Subject: [PATCH 24/70] fix: print a program, not an object --- eo-phi-normalizer/app/Main.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs index 415c0891e..335476861 100644 --- a/eo-phi-normalizer/app/Main.hs +++ b/eo-phi-normalizer/app/Main.hs @@ -60,7 +60,12 @@ main = do totalResults = length uniqueResults when (totalResults == 0) $ error "Could not normalize the program" if single - then logStrLn (printTree (head uniqueResults)) + then + logStrLn + ( case head uniqueResults of + [Formation bindings'] -> printTree $ Program bindings' + x -> printTree x + ) else do logStrLn "Input:" logStrLn (printTree input) From 64bdd1fa58bba360379873419b24cfc475d8209f Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 16:50:46 +0300 Subject: [PATCH 25/70] fix: set shell for pipeline --- .github/workflows/ghc.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index cf13d3e2a..1e747b91a 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -72,6 +72,7 @@ jobs: java-version: 21 - name: Run pipeline + shell: bash run: ./pipeline.sh haddock: From 8ec6513d2ffda4e89e5ee6c5ac93440886d8e20f Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 16:53:01 +0300 Subject: [PATCH 26/70] fix: remove silently --- pipeline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline.sh b/pipeline.sh index 6761cd766..c695921f4 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -8,7 +8,7 @@ alias eo="npx eoc --parser=${EO}" printf "\nClean the pipeline directory\n\n" -rm -r pipeline/*/ +rm -rf pipeline/*/ printf "\nGenerate EO test files\n\n" From 601a878f42813184eda6208b12ff3b0b1a449e8c Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 9 Feb 2024 21:24:00 +0300 Subject: [PATCH 27/70] fix: output with the `single` flag enabled --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ad5535fb..505b9685e 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ Use `--single` to print a single normalized program. stack run -- --single --rules-yaml ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml test.phi # Output -⟦ a ↦ ξ.b (c ↦ ⟦ ⟧).d (ρ ↦ ⟦ b ↦ ⟦ c ↦ ∅, d ↦ ⟦ φ ↦ ξ.ρ.c ⟧ ⟧ ⟧) ⟧ +{ a ↦ ξ.b (c ↦ ⟦ ⟧).d (ρ ↦ ⟦ b ↦ ⟦ c ↦ ∅, d ↦ ⟦ φ ↦ ξ.ρ.c ⟧ ⟧ ⟧) } ``` ## Rulesets From 309d24bfe8da56eac48a64e5c43fb7289fbcb2ea Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 13 Feb 2024 17:39:42 +0300 Subject: [PATCH 28/70] chore: update eo --- eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo b/eo index 4ced5a8e7..33bb3b6c6 160000 --- a/eo +++ b/eo @@ -1 +1 @@ -Subproject commit 4ced5a8e79394abbbc009dfab5a9fa43c4fcca74 +Subproject commit 33bb3b6c6bd5a2df6b641d364d8d841a967687c3 From a9c991ade2d937544917ea68c61cf3f2da7fea72 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 13 Feb 2024 17:39:58 +0300 Subject: [PATCH 29/70] chore: update eo parser version --- pipeline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline.sh b/pipeline.sh index c695921f4..1d6fb1bf6 100755 --- a/pipeline.sh +++ b/pipeline.sh @@ -3,7 +3,7 @@ set -euo pipefail if ! [ -d node_modules ]; then npm i; fi shopt -s expand_aliases -EO="0.34.1" +EO="0.35.2" alias eo="npx eoc --parser=${EO}" printf "\nClean the pipeline directory\n\n" From 4c83611ea044bedc159ed59d40f44b085f2e0b06 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 14 Feb 2024 15:59:19 +0300 Subject: [PATCH 30/70] fix: pipeline script location --- .github/workflows/ghc.yml | 2 +- flake.nix | 2 +- pipeline.sh => scripts/pipeline.sh | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename pipeline.sh => scripts/pipeline.sh (100%) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index 1e747b91a..f1e691413 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -73,7 +73,7 @@ jobs: - name: Run pipeline shell: bash - run: ./pipeline.sh + run: ./scripts/pipeline.sh haddock: needs: [build] diff --git a/flake.nix b/flake.nix index 03b4f8d99..8ef9fb8bf 100644 --- a/flake.nix +++ b/flake.nix @@ -155,7 +155,7 @@ text = let mkProgram = n: '' export PROGRAM="${builtins.toString n}" - ${builtins.readFile ./pipeline.sh} + ${builtins.readFile ./scripts/pipeline.sh} ''; in '' diff --git a/pipeline.sh b/scripts/pipeline.sh similarity index 100% rename from pipeline.sh rename to scripts/pipeline.sh From 31091ac56e514ecbd15b02771a2464968214a8b5 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 15 Feb 2024 21:54:30 +0300 Subject: [PATCH 31/70] fix: phi grammar --- eo-phi-normalizer/grammar/EO/Phi/Syntax.cf | 2 +- eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt | 4 ++-- eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x | 2 +- eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y | 2 +- eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf index 5253ffad3..357a655c0 100644 --- a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf @@ -10,7 +10,7 @@ token LabelId lower (char - [" \r\n\t,.|':;!?][}{)(⟧⟦"])* ; token AlphaIndex ({"α0"} | {"α"} (digit - ["0"]) (digit)* ) ; token MetaId {"!"} (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; -Program. Program ::= "{" [Binding] "}" ; +Program. Program ::= "{" "⟦" [Binding] "⟧" "}" ; Formation. Object ::= "⟦" [Binding] "⟧" ; Application. Object ::= Object "(" [Binding] ")" ; 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 cbf58b07a..84eca233f 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt @@ -44,7 +44,7 @@ The reserved words used in Syntax are the following: | ``ξ`` | ``ρ`` | ``σ`` | ``φ`` The symbols used in Syntax are the following: - | { | } | ⟦ | ⟧ + | { | ⟦ | ⟧ | } | ( | ) | . | ⊥ | ↦ | ∅ | ⤍ | , @@ -57,7 +57,7 @@ The symbols -> (production), **|** (union) and **eps** (empty rule) belong to the BNF notation. All other symbols are terminals. - | //Program// | -> | ``{`` //[Binding]// ``}`` + | //Program// | -> | ``{`` ``⟦`` //[Binding]// ``⟧`` ``}`` | //Object// | -> | ``⟦`` //[Binding]// ``⟧`` | | **|** | //Object// ``(`` //[Binding]// ``)`` | | **|** | //Object// ``.`` //Attribute// 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 bc087772b..044108f8c 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x @@ -28,7 +28,7 @@ $u = [. \n] -- universal: any character -- Symbols and non-identifier-like reserved words -@rsyms = \Φ | \ξ | \Δ | \λ | \φ | \ρ | \σ | \ν | \{ | \} | \⟦ | \⟧ | \( | \) | \. | \⊥ | \↦ | \∅ | \⤍ | \, +@rsyms = \Φ | \ξ | \Δ | \λ | \φ | \ρ | \σ | \ν | \{ | \⟦ | \⟧ | \} | \( | \) | \. | \⊥ | \↦ | \∅ | \⤍ | \, :- 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 73f3876bc..2dc83ae9f 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y @@ -86,7 +86,7 @@ MetaId : L_MetaId { Language.EO.Phi.Syntax.Abs.MetaId $1 } Program :: { Language.EO.Phi.Syntax.Abs.Program } Program - : '{' ListBinding '}' { Language.EO.Phi.Syntax.Abs.Program $2 } + : '{' '⟦' ListBinding '⟧' '}' { Language.EO.Phi.Syntax.Abs.Program $3 } Object :: { Language.EO.Phi.Syntax.Abs.Object } Object 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 0a781b042..f0c78e583 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs @@ -149,7 +149,7 @@ instance Print Language.EO.Phi.Syntax.Abs.MetaId where prt _ (Language.EO.Phi.Syntax.Abs.MetaId i) = doc $ showString i instance Print Language.EO.Phi.Syntax.Abs.Program where prt i = \case - Language.EO.Phi.Syntax.Abs.Program bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.Program bindings -> prPrec i 0 (concatD [doc (showString "{"), doc (showString "\10214"), prt 0 bindings, doc (showString "\10215"), doc (showString "}")]) instance Print Language.EO.Phi.Syntax.Abs.Object where prt i = \case From 54cef8532d4296252e6fa880fc8f224e2a077685 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 16 Feb 2024 14:52:27 +0300 Subject: [PATCH 32/70] chore: update eo to 0.35.3 --- eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo b/eo index 33bb3b6c6..b7423b025 160000 --- a/eo +++ b/eo @@ -1 +1 @@ -Subproject commit 33bb3b6c6bd5a2df6b641d364d8d841a967687c3 +Subproject commit b7423b0257fd8caa4e0beb31bfaf3fd5e95ffef3 From 1a1c22079e8fde4ebc9e2ae179c41915426badd6 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 16 Feb 2024 14:58:47 +0300 Subject: [PATCH 33/70] chore: update eolang --- package-lock.json | 68 +++++++++++++++++++++++++++++++++++------------ package.json | 2 +- 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index dfd24d3de..d1abcbca4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "devDependencies": { - "eolang": "^0.15.1" + "eolang": "^0.17.0" } }, "node_modules/@types/concat-stream": { @@ -102,12 +102,12 @@ } }, "node_modules/commander": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", - "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz", + "integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==", "dev": true, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/concat-stream": { @@ -156,9 +156,9 @@ } }, "node_modules/eolang": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/eolang/-/eolang-0.15.1.tgz", - "integrity": "sha512-zU7sZFH3Bv3VTKrg+/uLl13KNI1zFDfJNU8KkBddKdbeK4WRxrtg8FK/ZEIJ6OST6UE4w1ftaiotuYk6KRwBwg==", + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/eolang/-/eolang-0.17.0.tgz", + "integrity": "sha512-3B35u0yjtIkndKfmlUKqya6KHS5ijxQRoQoKBDkqIkUOfYwnLz406ifuqymoIFtSZDFLkxiV8wJTNyR9nmx79A==", "dev": true, "os": [ "darwin", @@ -167,10 +167,11 @@ ], "dependencies": { "colors": "1.4.0", - "commander": "11.1.0", - "fast-xml-parser": "4.3.2", - "node": "21.2.0", + "commander": "12.0.0", + "fast-xml-parser": "4.3.4", + "node": "21.6.1", "relative": "3.0.2", + "semver": "7.6.0", "sync-request": "6.1.0", "xmlhttprequest": "1.8.0" }, @@ -192,9 +193,9 @@ } }, "node_modules/fast-xml-parser": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.2.tgz", - "integrity": "sha512-rmrXUXwbJedoXkStenj1kkljNF7ugn5ZjR9FJcwmCfcCbtOMDghPajbc+Tck6vE6F5XsDmx+Pr2le9fw8+pXBg==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.4.tgz", + "integrity": "sha512-utnwm92SyozgA3hhH2I8qldf2lBqm6qHOICawRNRFu1qMe3+oqr+GcXjGqTmXTMGE5T4eC03kr/rlh5C1IRdZA==", "dev": true, "funding": [ { @@ -372,6 +373,18 @@ "node": ">=0.10.0" } }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -394,9 +407,9 @@ } }, "node_modules/node": { - "version": "21.2.0", - "resolved": "https://registry.npmjs.org/node/-/node-21.2.0.tgz", - "integrity": "sha512-oiHX7SXGdO1wyg0/lZ1ZMy1iS7GgumsT5Ptt5BOye1WniC8OJ2TtYRuWfqNoKrUlYzI4+Bv1+NH5eDgxuThU2A==", + "version": "21.6.1", + "resolved": "https://registry.npmjs.org/node/-/node-21.6.1.tgz", + "integrity": "sha512-cTqZk0/Wl6qeVcftyriVhHGFw1xvXl9o8TPI/qLcoVKh6X1dDKJGVi+EbhUg6864+KoDBnEaVxre59W8r8cLcA==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -493,6 +506,21 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, + "node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/set-function-length": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", @@ -614,6 +642,12 @@ "engines": { "node": ">=0.4.0" } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true } }, "devDependencies": { diff --git a/package.json b/package.json index 9415d9f91..fccc58be5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "devDependencies": { - "eolang": "^0.15.1" + "eolang": "^0.17.0" } } From 668f06bf6b423da016276155ba24c521f78b46c8 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 21 Feb 2024 12:17:43 +0300 Subject: [PATCH 34/70] refactor: merge "pipeline" and "build" jobs --- .github/workflows/ghc.yml | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index be619d9d1..8e6ce9488 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -15,8 +15,8 @@ permissions: contents: write # to submit Haddock documentation to GitHub Pages jobs: - build: - name: "Build and test with GHC" + pipeline: + name: Run pipeline runs-on: ${{ matrix.os }} strategy: matrix: @@ -40,29 +40,6 @@ jobs: with: stack-build-arguments: ${{ github.ref_name != 'master' && '--fast' || '' }} --pedantic - pipeline: - if: false - name: "Run pipeline" - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - macos-latest - - windows-latest - steps: - - name: 📥 Checkout repository - uses: actions/checkout@v4 - with: - submodules: true - - - name: 🧰 Setup Stack - uses: freckle/stack-action@v5 - with: - test: false - stack-build-arguments: --${{ github.ref_name != 'master' && 'fast' || '' }} --pedantic - - uses: actions/setup-node@v4 with: node-version: 20 @@ -77,7 +54,7 @@ jobs: run: ./scripts/pipeline.sh docs: - needs: [build] + needs: [pipeline] if: ${{ github.ref_name == 'master' }} name: "Build and upload site (master)" runs-on: ubuntu-latest From 4266c6d3242bd3099cd18ea63fa06c22ba8f9321 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 29 Feb 2024 17:27:28 +0300 Subject: [PATCH 35/70] fix: demand recurse-submodules --- site/docs/src/commands/normalizer-transform.md | 2 +- site/docs/src/contributing.md | 2 +- site/docs/src/installation.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/site/docs/src/commands/normalizer-transform.md b/site/docs/src/commands/normalizer-transform.md index 22b39f4c5..a359f0465 100644 --- a/site/docs/src/commands/normalizer-transform.md +++ b/site/docs/src/commands/normalizer-transform.md @@ -53,7 +53,7 @@ The commands in the following sections access files that are available in the pr Clone and enter the repository directory. ```sh -git clone https://github.com/objectionary/normalizer +git clone https://github.com/objectionary/normalizer --recurse-submodules cd normalizer ``` diff --git a/site/docs/src/contributing.md b/site/docs/src/contributing.md index ebd39e43a..78587187d 100644 --- a/site/docs/src/contributing.md +++ b/site/docs/src/contributing.md @@ -5,7 +5,7 @@ We recommend using [stack](https://docs.haskellstack.org/en/stable/README/) for Clone this project and run `stack build`. ```sh -git clone https://github.com/objectionary/normalizer +git clone https://github.com/objectionary/normalizer --recurse-submodules cd normalizer stack build ``` diff --git a/site/docs/src/installation.md b/site/docs/src/installation.md index 8241bce77..cf4fed130 100644 --- a/site/docs/src/installation.md +++ b/site/docs/src/installation.md @@ -6,7 +6,7 @@ Then, the `normalizer` executable will be available on `PATH`. ## Install from the repository ```sh -git clone https://github.com/objectionary/normalizer +git clone https://github.com/objectionary/normalizer --recurse-submodules cd normalizer export LANG=C.UTF-8 stack install normalizer From 465a131960ed9c4ccd7b972de3600a9e18887e15 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 1 Mar 2024 13:19:23 +0300 Subject: [PATCH 36/70] refactor: format, add type --- scripts/transform-eo-tests/app/Main.hs | 141 +++++++++++++------------ 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/scripts/transform-eo-tests/app/Main.hs b/scripts/transform-eo-tests/app/Main.hs index 1a769c34a..16e58a46d 100644 --- a/scripts/transform-eo-tests/app/Main.hs +++ b/scripts/transform-eo-tests/app/Main.hs @@ -18,7 +18,7 @@ import Data.Function ((&)) import Data.Functor ((<&>)) import Data.String (IsString (..)) import Data.Text qualified as T -import Data.Yaml (FromJSON, ToJSON (..), Value (String), decodeFileThrow, encodeFile) +import Data.Yaml (FromJSON, Parser, ToJSON (..), Value (String), decodeFileThrow, encodeFile) import Data.Yaml.Aeson (FromJSON (..), withText) import GHC.Generics (Generic) import Main.Utf8 (withUtf8) @@ -28,99 +28,100 @@ import Text.Read (readMaybe) main :: IO () main = withUtf8 do - let testDir = "pipeline" - config <- decodeFileThrow @_ @TestConfig (testDir "config.yaml") - createDirectoryIfMissing True config.yamlDirectory - forM_ config.sets $ \set -> do - test@Test{source, meta, license} <- parseTest set.source - let programs = filter (\x -> x.name `elem` set.programs) test.programs - testContent = TestContent{..} - - -- write yaml - let target = set.yaml - targetTmp = target <.> ".tmp" - createDirectoryIfMissing True (takeDirectory target) - writeFile target license - encodeFile targetTmp testContent - readFile targetTmp >>= appendFile target - removeFile targetTmp - - -- write eo - createDirectoryIfMissing True (takeDirectory set.destination) - writeFile set.destination (license <> meta) - forM_ programs (\x -> appendFile set.destination x.text) + let testDir = "pipeline" + config <- decodeFileThrow @_ @TestConfig (testDir "config.yaml") + createDirectoryIfMissing True config.yamlDirectory + forM_ config.sets $ \set -> do + test@Test{source, meta, license} <- parseTest set.source + let programs = filter (\x -> x.name `elem` set.programs) test.programs + testContent = TestContent{..} + + -- write yaml + let target = set.yaml + targetTmp = target <.> ".tmp" + createDirectoryIfMissing True (takeDirectory target) + writeFile target license + encodeFile targetTmp testContent + readFile targetTmp >>= appendFile target + removeFile targetTmp + + -- write eo + createDirectoryIfMissing True (takeDirectory set.destination) + writeFile set.destination (license <> meta) + forM_ programs (\x -> appendFile set.destination x.text) data TestSet = TestSet - { source :: FilePath - , yaml :: FilePath - , destination :: FilePath - , programs :: [String] - } - deriving (Show, Generic, FromJSON) + { source :: FilePath + , yaml :: FilePath + , destination :: FilePath + , programs :: [String] + } + deriving (Show, Generic, FromJSON) data TestConfig = TestConfig - { yamlDirectory :: FilePath - , sets :: [TestSet] - } - deriving (Show, Generic, FromJSON) + { yamlDirectory :: FilePath + , sets :: [TestSet] + } + deriving (Show, Generic, FromJSON) data Pos = Pos - { file :: FilePath - , line :: Int - } - deriving (Show) + { file :: FilePath + , line :: Int + } + deriving (Show) instance ToJSON Pos where - toJSON :: Pos -> Value - toJSON Pos{..} = String (fromString (file <> ":" <> show line)) + toJSON :: Pos -> Value + toJSON Pos{..} = String (fromString (file <> ":" <> show line)) instance FromJSON Pos where - parseJSON = withText "Pos" $ \(T.unpack -> x) -> do - let (file, rs) = span (/= ':') x - guard (not . null $ file) - guard (length rs > 1) - let line' = readMaybe (drop 1 rs) - maybe (fail $ x <> " is not a number") (\line -> pure Pos{..}) line' + parseJSON :: Value -> Parser Pos + parseJSON = withText "Pos" $ \(T.unpack -> x) -> do + let (file, rs) = span (/= ':') x + guard (not . null $ file) + guard (length rs > 1) + let line' = readMaybe (drop 1 rs) + maybe (fail $ x <> " is not a number") (\line -> pure Pos{..}) line' data Program = Program - { source :: Pos - , name :: String - , text :: String - } - deriving (Show, Generic, ToJSON, FromJSON) + { source :: Pos + , name :: String + , text :: String + } + deriving (Show, Generic, ToJSON, FromJSON) data Test = Test - { source :: String - , license :: String - , meta :: String - , programs :: [Program] - } - deriving (Show, Generic, ToJSON, FromJSON) + { source :: String + , license :: String + , meta :: String + , programs :: [Program] + } + deriving (Show, Generic, ToJSON, FromJSON) data TestContent = TestContent - { source :: FilePath - , meta :: String - , programs :: [Program] - } - deriving (Show, Generic, ToJSON, FromJSON) + { source :: FilePath + , meta :: String + , programs :: [Program] + } + deriving (Show, Generic, ToJSON, FromJSON) parseProgramsRaw :: ([(Int, [String])], (Int, [[Char]]), Int) -> [[Char]] -> [(Int, String)] parseProgramsRaw (programs', (programStart, program), curLine) (line'@(x : _) : xs) - | (program /= [] && head program == "" || null program) && (x == '[' || x == '#') = parseProgramsRaw ((programStart, program) : programs', (curLine, [line']), curLine + 1) xs - | otherwise = parseProgramsRaw (programs', (programStart, line' : program), curLine + 1) xs + | (program /= [] && head program == "" || null program) && (x == '[' || x == '#') = parseProgramsRaw ((programStart, program) : programs', (curLine, [line']), curLine + 1) xs + | otherwise = parseProgramsRaw (programs', (programStart, line' : program), curLine + 1) xs parseProgramsRaw (programs', (programStart, program), curLine) ("" : xs) = parseProgramsRaw (programs', (programStart, "" : program), curLine + 1) xs parseProgramsRaw (programs', program, _) [] = (unlines <$>) <$> drop 1 (reverse ((reverse <$>) <$> (program : programs'))) parseTest' :: FilePath -> [String] -> Test parseTest' source eoCode = - let - (license, k') = span (\case '#' : _ -> True; "" -> True; _ -> False) eoCode - (meta, k'') = span (\case '+' : _ -> True; "" -> True; _ -> False) k' - programsStart = length license + length meta + 1 - programsRaw = parseProgramsRaw ([], (programsStart, []), programsStart) k'' - programs = programsRaw <&> (\(line, text) -> Program{source = Pos{file = source, ..}, name = text & dropWhile (/= '[') & drop 5 & takeWhile (/= '\n'), ..}) - in - Test{license = unlines license, meta = unlines meta, ..} + let + (license, k') = span (\case '#' : _ -> True; "" -> True; _ -> False) eoCode + (meta, k'') = span (\case '+' : _ -> True; "" -> True; _ -> False) k' + programsStart = length license + length meta + 1 + programsRaw = parseProgramsRaw ([], (programsStart, []), programsStart) k'' + programs = programsRaw <&> (\(line, text) -> Program{source = Pos{file = source, ..}, name = text & dropWhile (/= '[') & drop 5 & takeWhile (/= '\n'), ..}) + in + Test{license = unlines license, meta = unlines meta, ..} parseTest :: FilePath -> IO Test parseTest path = readFile path <&> (parseTest' path . lines) From 3ddfa8343241a960d70d94d70d276f569dbaf496 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 1 Mar 2024 13:20:22 +0300 Subject: [PATCH 37/70] chore: update eo to 0.35.5 --- eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo b/eo index b7423b025..9759a327a 160000 --- a/eo +++ b/eo @@ -1 +1 @@ -Subproject commit b7423b0257fd8caa4e0beb31bfaf3fd5e95ffef3 +Subproject commit 9759a327a2609ae91c882412e495367dded234bd From 67e2b2e687779d90e108ee58cc6ce5be14dd0cc8 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 1 Mar 2024 13:23:20 +0300 Subject: [PATCH 38/70] fix: pipeline script - use eo parser 0.35.5 - update normalizer command - support eo and phi in subdirectories --- scripts/pipeline.sh | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 1d6fb1bf6..2f248d7f5 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -3,7 +3,7 @@ set -euo pipefail if ! [ -d node_modules ]; then npm i; fi shopt -s expand_aliases -EO="0.35.2" +EO="0.35.5" alias eo="npx eoc --parser=${EO}" printf "\nClean the pipeline directory\n\n" @@ -27,7 +27,7 @@ mkdir -p phi cd eo eo clean eo phi -cp .eoc/phi/*.phi ../phi +rsync -r .eoc/phi/* --exclude org ../phi cd .. @@ -35,17 +35,29 @@ printf "\nConvert PHI to EO without normalization\n\n" mkdir -p eo-not-normalized cd phi -cp -r ../eo/.eoc . +rsync -r ../eo/.eoc . eo unphi -cp .eoc/unphi/*.xmir ".eoc/2-optimize" +rsync -r .eoc/unphi/* --exclude org .eoc/2-optimize eo print -cp .eoc/print/*.eo ../eo-not-normalized +rsync -r .eoc/print/* --exclude org ../eo-not-normalized cd .. +function add_metas { + EO_FILES="$(find -name '*.eo' -not -path '.eoc/**')" + for f in $EO_FILES; + do + cat $f > $f.bk + printf "+tests\n" > $f + cat $f.bk >> $f + rm $f.bk + done +} + printf "\nTest EO without normalization\n\n" cd eo-not-normalized +add_metas eo test cd .. @@ -54,13 +66,17 @@ printf "\nNormalize PHI\n\n" mkdir -p phi-normalized cd phi -for f in $(ls); do +PHI_FILES="$(find -name '*.phi' -not -path '.eoc/**')" +for f in $PHI_FILES; do + destination="../phi-normalized/$f" + mkdir -p $(dirname $destination) stack run -- \ - -s \ - --rules-yaml \ + transform \ + --single \ + --rules \ ../../eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \ "$f" \ - > "../phi-normalized/$f" + > $destination done cd .. @@ -68,9 +84,9 @@ cd .. printf "\nConvert normalized PHI to EO\n\n" cd phi-normalized -cp -r ../eo/.eoc . +rsync -r ../eo/.eoc . eo unphi -cp .eoc/unphi/*.xmir ".eoc/2-optimize" +rsync -r .eoc/unphi/* --exclude org .eoc/2-optimize eo print cd .. @@ -79,6 +95,7 @@ printf "\nTest EO\n\n" mkdir -p eo-normalized cd eo-normalized -cp ../phi-normalized/.eoc/print/*.eo . +rsync -r ../phi-normalized/.eoc/print/* --exclude org . +add_metas eo test cd .. From 6f8f23b57c0339cd3a536e935a3eef9c00dfe8e6 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 1 Mar 2024 13:46:46 +0300 Subject: [PATCH 39/70] refactor: partition pipeline into functions --- scripts/pipeline.sh | 147 ++++++++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 68 deletions(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 2f248d7f5..4bf728879 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -6,96 +6,107 @@ shopt -s expand_aliases EO="0.35.5" alias eo="npx eoc --parser=${EO}" -printf "\nClean the pipeline directory\n\n" +function prepare_directory { + printf "\nClean the pipeline directory\n\n" -rm -rf pipeline/*/ + rm -rf pipeline/*/ + printf "\nGenerate EO test files\n\n" -printf "\nGenerate EO test files\n\n" + stack run transform-eo-tests +} -stack run transform-eo-tests +function enter_directory { + printf "\nEnter the pipeline directory\n\n" + cd pipeline +} -printf "\nEnter the pipeline directory\n\n" -cd pipeline +function tests_without_normalization { + printf "\nConvert EO to PHI\n\n" + mkdir -p phi + cd eo + eo clean + eo phi + rsync -r .eoc/phi/* --exclude org ../phi + cd .. -printf "\nConvert EO to PHI\n\n" -mkdir -p phi -cd eo -eo clean -eo phi -rsync -r .eoc/phi/* --exclude org ../phi -cd .. + printf "\nConvert PHI to EO without normalization\n\n" + mkdir -p eo-not-normalized + cd phi + rsync -r ../eo/.eoc . + eo unphi + rsync -r .eoc/unphi/* --exclude org .eoc/2-optimize + eo print + rsync -r .eoc/print/* --exclude org ../eo-not-normalized + cd .. -printf "\nConvert PHI to EO without normalization\n\n" -mkdir -p eo-not-normalized -cd phi -rsync -r ../eo/.eoc . -eo unphi -rsync -r .eoc/unphi/* --exclude org .eoc/2-optimize -eo print -rsync -r .eoc/print/* --exclude org ../eo-not-normalized -cd .. + function add_metas { + EO_FILES="$(find -name '*.eo' -not -path '.eoc/**')" + for f in $EO_FILES; + do + cat $f > $f.bk + printf "+tests\n" > $f + cat $f.bk >> $f + rm $f.bk + done + } + printf "\nTest EO without normalization\n\n" -function add_metas { - EO_FILES="$(find -name '*.eo' -not -path '.eoc/**')" - for f in $EO_FILES; - do - cat $f > $f.bk - printf "+tests\n" > $f - cat $f.bk >> $f - rm $f.bk - done + cd eo-not-normalized + add_metas + eo test + cd .. } -printf "\nTest EO without normalization\n\n" - -cd eo-not-normalized -add_metas -eo test -cd .. +function tests_with_normalization { + printf "\nNormalize PHI\n\n" + + mkdir -p phi-normalized + cd phi + PHI_FILES="$(find -name '*.phi' -not -path '.eoc/**')" + for f in $PHI_FILES; do + destination="../phi-normalized/$f" + mkdir -p $(dirname $destination) + stack run -- \ + transform \ + --single \ + --rules \ + ../../eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \ + "$f" \ + > $destination + done + cd .. -printf "\nNormalize PHI\n\n" - -mkdir -p phi-normalized -cd phi -PHI_FILES="$(find -name '*.phi' -not -path '.eoc/**')" -for f in $PHI_FILES; do - destination="../phi-normalized/$f" - mkdir -p $(dirname $destination) - stack run -- \ - transform \ - --single \ - --rules \ - ../../eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \ - "$f" \ - > $destination -done -cd .. + printf "\nConvert normalized PHI to EO\n\n" -printf "\nConvert normalized PHI to EO\n\n" + cd phi-normalized + rsync -r ../eo/.eoc . + eo unphi + rsync -r .eoc/unphi/* --exclude org .eoc/2-optimize + eo print + cd .. -cd phi-normalized -rsync -r ../eo/.eoc . -eo unphi -rsync -r .eoc/unphi/* --exclude org .eoc/2-optimize -eo print -cd .. + printf "\nTest EO\n\n" -printf "\nTest EO\n\n" + mkdir -p eo-normalized + cd eo-normalized + rsync -r ../phi-normalized/.eoc/print/* --exclude org . + add_metas + eo test + cd .. +} -mkdir -p eo-normalized -cd eo-normalized -rsync -r ../phi-normalized/.eoc/print/* --exclude org . -add_metas -eo test -cd .. +prepare_directory +enter_directory +tests_without_normalization +tests_with_normalization From bd85cf1792f155d0738f0492292d4f84bddb4730 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 1 Mar 2024 13:47:18 +0300 Subject: [PATCH 40/70] fix: disable normalizer --- scripts/pipeline.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 4bf728879..4b8784d93 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -75,13 +75,17 @@ function tests_with_normalization { for f in $PHI_FILES; do destination="../phi-normalized/$f" mkdir -p $(dirname $destination) - stack run -- \ - transform \ - --single \ - --rules \ - ../../eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \ - "$f" \ - > $destination + cp $f $destination + + # TODO #100:5min run normalizer instead + + # stack run -- \ + # transform \ + # --single \ + # --rules \ + # ../../eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \ + # "$f" \ + # > $destination done cd .. From 23782d65b00d3183314f0811adde5615c88e3426 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Sun, 3 Mar 2024 21:22:18 +0300 Subject: [PATCH 41/70] fix: add metas --- scripts/pipeline.sh | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 4b8784d93..c7f973a9e 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -13,6 +13,7 @@ function prepare_directory { printf "\nGenerate EO test files\n\n" + mkdir -p pipeline/eo stack run transform-eo-tests } @@ -22,6 +23,16 @@ function enter_directory { cd pipeline } +function add_metas { + EO_FILES="$(find -name '*.eo' -not -path '.eoc/**')" + for f in $EO_FILES; + do + cat $f > $f.bk + printf "+tests\n" > $f + cat $f.bk >> $f + rm $f.bk + done +} function tests_without_normalization { printf "\nConvert EO to PHI\n\n" @@ -30,7 +41,7 @@ function tests_without_normalization { cd eo eo clean eo phi - rsync -r .eoc/phi/* --exclude org ../phi + rsync -r .eoc/phi/ --exclude org ../phi cd .. @@ -40,23 +51,11 @@ function tests_without_normalization { cd phi rsync -r ../eo/.eoc . eo unphi - rsync -r .eoc/unphi/* --exclude org .eoc/2-optimize + rsync -r .eoc/unphi/ --exclude org .eoc/2-optimize eo print - rsync -r .eoc/print/* --exclude org ../eo-not-normalized + rsync -r .eoc/print/ --exclude org ../eo-not-normalized cd .. - - function add_metas { - EO_FILES="$(find -name '*.eo' -not -path '.eoc/**')" - for f in $EO_FILES; - do - cat $f > $f.bk - printf "+tests\n" > $f - cat $f.bk >> $f - rm $f.bk - done - } - printf "\nTest EO without normalization\n\n" cd eo-not-normalized @@ -95,7 +94,7 @@ function tests_with_normalization { cd phi-normalized rsync -r ../eo/.eoc . eo unphi - rsync -r .eoc/unphi/* --exclude org .eoc/2-optimize + rsync -r .eoc/unphi/ --exclude org .eoc/2-optimize eo print cd .. From b008999a9a0343a56d1d0d8880ce46c3aa794fd8 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Sun, 3 Mar 2024 21:22:50 +0300 Subject: [PATCH 42/70] feat: add try-unphi script --- scripts/try-unphi.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 scripts/try-unphi.sh diff --git a/scripts/try-unphi.sh b/scripts/try-unphi.sh new file mode 100755 index 000000000..393b78bdc --- /dev/null +++ b/scripts/try-unphi.sh @@ -0,0 +1,69 @@ +set -euo pipefail + +if ! [ -d node_modules ]; then npm i; fi + +shopt -s expand_aliases +EO="0.35.5" +alias eo="npx eoc --parser=${EO}" + +DIR=try-unphi + +function prepare_directory { + printf "\nClean the $DIR directory\n\n" + + mkdir -p $DIR/init + mkdir -p $DIR/phi + mkdir -p $DIR/tmp + mkdir -p $DIR/unphi +} + +function enter_directory { + printf "\nEnter the $DIR directory\n\n" + + cd $DIR +} + +function init_eoc { + printf "\nGenerate an initial .eoc directory\n\n" + + cd init + + if [ ! -d .eoc ]; then + cat < test.eo ++alias org.eolang.io.stdout ++architect yegor256@gmail.com ++home https://github.com/objectionary/eo ++tests ++package org.eolang ++version 0.0.0 + +# Test. +[] > prints-itself + gt. > @ + length. + as-phi $ + 0 +EOM + eo phi + fi + + cd .. +} + +function unphi { + printf "\nUnphi\n\n" + + cd tmp + rsync -r ../phi/ . + rsync -r ../init/.eoc . + eo unphi + rsync -r .eoc/unphi/ --exclude org .eoc/2-optimize + eo print + rsync -r .eoc/print/ --exclude org ../unphi + cd .. +} + +prepare_directory +enter_directory +init_eoc +unphi From b94786abcc1d346bac34ce58f58065849b66fb65 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Mon, 4 Mar 2024 18:25:13 +0300 Subject: [PATCH 43/70] fix: enable stack in pipeline --- scripts/pipeline.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index c7f973a9e..4a028b94d 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -74,17 +74,14 @@ function tests_with_normalization { for f in $PHI_FILES; do destination="../phi-normalized/$f" mkdir -p $(dirname $destination) - cp $f $destination - # TODO #100:5min run normalizer instead - - # stack run -- \ - # transform \ - # --single \ - # --rules \ - # ../../eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \ - # "$f" \ - # > $destination + stack run -- \ + transform \ + --single \ + --rules \ + ../../eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \ + "$f" \ + > $destination done cd .. From c933eb0e0753d3a155de9fa7dec588a7cb136273 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 5 Mar 2024 09:53:39 +0300 Subject: [PATCH 44/70] fix: comment out rule 5 --- .../test/eo/phi/rules/yegor.yaml | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml b/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml index bbff3af91..135e198cc 100644 --- a/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml +++ b/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml @@ -94,24 +94,24 @@ rules: # when: [] # tests: [] - - name: Rule 5 - description: 'ξ-dispatch' - context: - current_object: '⟦ !a ↦ !obj, !B ⟧' - current_attribute: '!a' - pattern: | - ξ - result: | - ⟦ !B ⟧ - when: - - present_attrs: - attrs: ['ν', 'σ', 'ρ'] - bindings: ['!B'] - tests: - - name: Replaces ξ with the actual object - input: '⟦ a ↦ ⟦ ⟧, x ↦ ξ.a, ν ↦ ⟦ ⟧, σ ↦ ⟦ ⟧, ρ ↦ ⟦ ⟧ ⟧' - output: - - '⟦ a ↦ ⟦ ⟧, x ↦ ⟦ a ↦ ⟦ ⟧, ν ↦ ⟦ ⟧, σ ↦ ⟦ ⟧, ρ ↦ ⟦ ⟧ ⟧.a, ν ↦ ⟦ ⟧, σ ↦ ⟦ ⟧, ρ ↦ ⟦ ⟧ ⟧' + # - name: Rule 5 + # description: 'ξ-dispatch' + # context: + # current_object: '⟦ !a ↦ !obj, !B ⟧' + # current_attribute: '!a' + # pattern: | + # ξ + # result: | + # ⟦ !B ⟧ + # when: + # - present_attrs: + # attrs: ['ν', 'σ', 'ρ'] + # bindings: ['!B'] + # tests: + # - name: Replaces ξ with the actual object + # input: '⟦ a ↦ ⟦ ⟧, x ↦ ξ.a, ν ↦ ⟦ ⟧, σ ↦ ⟦ ⟧, ρ ↦ ⟦ ⟧ ⟧' + # output: + # - '⟦ a ↦ ⟦ ⟧, x ↦ ⟦ a ↦ ⟦ ⟧, ν ↦ ⟦ ⟧, σ ↦ ⟦ ⟧, ρ ↦ ⟦ ⟧ ⟧.a, ν ↦ ⟦ ⟧, σ ↦ ⟦ ⟧, ρ ↦ ⟦ ⟧ ⟧' - name: Rule 6 description: 'Accessing an α-binding' From 502966ac9ced1fa99cc82deb45fef360a53d52f7 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 5 Mar 2024 10:08:12 +0300 Subject: [PATCH 45/70] fix: checkout submodules --- .github/workflows/ghc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index fd0135a47..023c57255 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -52,6 +52,8 @@ jobs: steps: - name: 📥 Checkout repository uses: actions/checkout@v4 + with: + submodules: true - name: 🧰 Setup Stack uses: freckle/stack-action@v5 From ea83b7bf66124e71ece44bff4abff5f926bc07d5 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 5 Mar 2024 10:25:15 +0300 Subject: [PATCH 46/70] fix: use LC_ALL everywhere --- flake.nix | 2 +- scripts/pipeline.sh | 2 ++ site/docs/src/installation.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index a13c46fbe..e9d40e80f 100644 --- a/flake.nix +++ b/flake.nix @@ -177,7 +177,7 @@ stack ]; text = '' - export LANG=C.utf8 + export LC_ALL=C.UTF-8 mdsh # create sample program mdsh -i site/docs/src/common/sample-program.md --work_dir . diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 4a028b94d..1856db06e 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -2,6 +2,8 @@ set -euo pipefail if ! [ -d node_modules ]; then npm i; fi +export LC_ALL=C.UTF-8 + shopt -s expand_aliases EO="0.35.5" alias eo="npx eoc --parser=${EO}" diff --git a/site/docs/src/installation.md b/site/docs/src/installation.md index cf4fed130..cff08f5fe 100644 --- a/site/docs/src/installation.md +++ b/site/docs/src/installation.md @@ -8,7 +8,7 @@ Then, the `normalizer` executable will be available on `PATH`. ```sh git clone https://github.com/objectionary/normalizer --recurse-submodules cd normalizer -export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 stack install normalizer ``` @@ -16,7 +16,7 @@ stack install normalizer ```sh stack update -export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 stack install --resolver lts-22.11 eo-phi-normalizer ``` From 32501dca718d00b025b02900f1bec3e49e3d6708 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 5 Mar 2024 10:32:38 +0300 Subject: [PATCH 47/70] try: set LC_ALL --- .github/workflows/ghc.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index 023c57255..efbf9f2f9 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -59,6 +59,8 @@ jobs: uses: freckle/stack-action@v5 with: stack-build-arguments: ${{ github.ref_name != 'master' && '--fast' || '' }} --pedantic + env: + LC_ALL: C.UTF-8 - uses: actions/setup-node@v4 with: @@ -97,7 +99,7 @@ jobs: - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: - mdbook-version: 'latest' + mdbook-version: "latest" - name: Build site run: | From 0637f1cfbda9aadd4e30749c5729fd496a02f33f Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 5 Mar 2024 11:22:33 +0300 Subject: [PATCH 48/70] try: debug stack-action --- .github/workflows/ghc.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index efbf9f2f9..d1aee7730 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -59,8 +59,10 @@ jobs: uses: freckle/stack-action@v5 with: stack-build-arguments: ${{ github.ref_name != 'master' && '--fast' || '' }} --pedantic - env: - LC_ALL: C.UTF-8 + test: false + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 - uses: actions/setup-node@v4 with: From e0dde464d24d3232a3d0c969d19b11dcef67168a Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 6 Mar 2024 19:24:22 +0300 Subject: [PATCH 49/70] fix: update eo and unphi --- scripts/pipeline.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 1856db06e..5d3b2de7a 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -5,7 +5,7 @@ if ! [ -d node_modules ]; then npm i; fi export LC_ALL=C.UTF-8 shopt -s expand_aliases -EO="0.35.5" +EO="0.35.7" alias eo="npx eoc --parser=${EO}" function prepare_directory { @@ -52,7 +52,7 @@ function tests_without_normalization { mkdir -p eo-not-normalized cd phi rsync -r ../eo/.eoc . - eo unphi + eo unphi --tests rsync -r .eoc/unphi/ --exclude org .eoc/2-optimize eo print rsync -r .eoc/print/ --exclude org ../eo-not-normalized @@ -92,7 +92,7 @@ function tests_with_normalization { cd phi-normalized rsync -r ../eo/.eoc . - eo unphi + eo unphi --tests rsync -r .eoc/unphi/ --exclude org .eoc/2-optimize eo print cd .. From 8c1135d619890caf68cec3bbe0d47ab8af72fd04 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 6 Mar 2024 20:26:20 +0300 Subject: [PATCH 50/70] fix: disable tests on Windows --- .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 d1aee7730..9e08b0281 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -59,7 +59,7 @@ jobs: uses: freckle/stack-action@v5 with: stack-build-arguments: ${{ github.ref_name != 'master' && '--fast' || '' }} --pedantic - test: false + test: ${{ matrix.os != 'windows-latest' }} - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From 1f156de695a34be5e892e259663c841553ce39aa Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 6 Mar 2024 20:27:15 +0300 Subject: [PATCH 51/70] fix: upgrade eo --- package-lock.json | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index d1abcbca4..9937b95ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "devDependencies": { - "eolang": "^0.17.0" + "eolang": "^0.18.0" } }, "node_modules/@types/concat-stream": { @@ -156,9 +156,9 @@ } }, "node_modules/eolang": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/eolang/-/eolang-0.17.0.tgz", - "integrity": "sha512-3B35u0yjtIkndKfmlUKqya6KHS5ijxQRoQoKBDkqIkUOfYwnLz406ifuqymoIFtSZDFLkxiV8wJTNyR9nmx79A==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/eolang/-/eolang-0.18.0.tgz", + "integrity": "sha512-QepfFJ+aVFQdIjFEQm8TSCVAK6c5SpKBg9/TZq/Vqdbb9FXJKrn5loZQAInsG4+YM1GSZfW/fhtu4tB45Fk9Bg==", "dev": true, "os": [ "darwin", @@ -168,7 +168,7 @@ "dependencies": { "colors": "1.4.0", "commander": "12.0.0", - "fast-xml-parser": "4.3.4", + "fast-xml-parser": "4.3.5", "node": "21.6.1", "relative": "3.0.2", "semver": "7.6.0", @@ -193,9 +193,9 @@ } }, "node_modules/fast-xml-parser": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.4.tgz", - "integrity": "sha512-utnwm92SyozgA3hhH2I8qldf2lBqm6qHOICawRNRFu1qMe3+oqr+GcXjGqTmXTMGE5T4eC03kr/rlh5C1IRdZA==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.5.tgz", + "integrity": "sha512-sWvP1Pl8H03B8oFJpFR3HE31HUfwtX7Rlf9BNsvdpujD4n7WMhfmu8h9wOV2u+c1k0ZilTADhPqypzx2J690ZQ==", "dev": true, "funding": [ { diff --git a/package.json b/package.json index fccc58be5..87cf6e871 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "devDependencies": { - "eolang": "^0.17.0" + "eolang": "^0.18.0" } } From 564a5d0738cbfa4c96e08296bd7337e06d1a3c64 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 6 Mar 2024 20:28:17 +0300 Subject: [PATCH 52/70] fix: disable tmate --- .github/workflows/ghc.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index 9e08b0281..1b0378812 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -61,9 +61,6 @@ jobs: stack-build-arguments: ${{ github.ref_name != 'master' && '--fast' || '' }} --pedantic test: ${{ matrix.os != 'windows-latest' }} - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - - uses: actions/setup-node@v4 with: node-version: 20 From c2a5af1473da077af03d08572ce4be72b6c46597 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 6 Mar 2024 20:33:24 +0300 Subject: [PATCH 53/70] feat: don't fail-fast in pipeline --- .github/workflows/ghc.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index 1b0378812..4b8240bac 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -48,6 +48,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] + fail-fast: false steps: - name: 📥 Checkout repository From a1792001aa5e93f150d32735d397bf27c6cc6c6b Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 6 Mar 2024 21:07:07 +0300 Subject: [PATCH 54/70] fix: eo version --- scripts/pipeline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 5d3b2de7a..601aebaad 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -5,7 +5,7 @@ if ! [ -d node_modules ]; then npm i; fi export LC_ALL=C.UTF-8 shopt -s expand_aliases -EO="0.35.7" +EO="0.35.6" alias eo="npx eoc --parser=${EO}" function prepare_directory { From 3d83dd298b4a628015cf156ad070b260a49110c8 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 6 Mar 2024 22:57:00 +0300 Subject: [PATCH 55/70] fix: use cross-platform commands --- scripts/pipeline.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 601aebaad..9b5d69d54 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -8,6 +8,8 @@ shopt -s expand_aliases EO="0.35.6" alias eo="npx eoc --parser=${EO}" +shopt -s extglob + function prepare_directory { printf "\nClean the pipeline directory\n\n" @@ -43,7 +45,7 @@ function tests_without_normalization { cd eo eo clean eo phi - rsync -r .eoc/phi/ --exclude org ../phi + cp -r .eoc/phi/!(org) ../phi cd .. @@ -51,11 +53,11 @@ function tests_without_normalization { mkdir -p eo-not-normalized cd phi - rsync -r ../eo/.eoc . + cp -r ../eo/.eoc . eo unphi --tests - rsync -r .eoc/unphi/ --exclude org .eoc/2-optimize + cp -r .eoc/unphi/!(org) .eoc/2-optimize eo print - rsync -r .eoc/print/ --exclude org ../eo-not-normalized + cp -r .eoc/print/!(org) ../eo-not-normalized cd .. printf "\nTest EO without normalization\n\n" @@ -91,9 +93,9 @@ function tests_with_normalization { printf "\nConvert normalized PHI to EO\n\n" cd phi-normalized - rsync -r ../eo/.eoc . + cp -r ../eo/.eoc . eo unphi --tests - rsync -r .eoc/unphi/ --exclude org .eoc/2-optimize + cp -r .eoc/unphi/!(org) .eoc/2-optimize eo print cd .. @@ -102,7 +104,7 @@ function tests_with_normalization { mkdir -p eo-normalized cd eo-normalized - rsync -r ../phi-normalized/.eoc/print/* --exclude org . + cp -r ../phi-normalized/.eoc/print/!(org) . add_metas eo test cd .. From 6cf27b4d340c595d6ea20b83efeef24b15887c9b Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 00:07:27 +0300 Subject: [PATCH 56/70] fix: remove add_metas, fix "find" command --- scripts/pipeline.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 9b5d69d54..7290194ae 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -27,17 +27,6 @@ function enter_directory { cd pipeline } -function add_metas { - EO_FILES="$(find -name '*.eo' -not -path '.eoc/**')" - for f in $EO_FILES; - do - cat $f > $f.bk - printf "+tests\n" > $f - cat $f.bk >> $f - rm $f.bk - done -} - function tests_without_normalization { printf "\nConvert EO to PHI\n\n" @@ -63,7 +52,6 @@ function tests_without_normalization { printf "\nTest EO without normalization\n\n" cd eo-not-normalized - add_metas eo test cd .. } @@ -105,7 +93,6 @@ function tests_with_normalization { mkdir -p eo-normalized cd eo-normalized cp -r ../phi-normalized/.eoc/print/!(org) . - add_metas eo test cd .. } From 178945c271970ce51eb30c4c922ead2348e9b98f Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 00:07:40 +0300 Subject: [PATCH 57/70] fix: "find" command arguments --- scripts/pipeline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 7290194ae..3d1505ea8 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -62,7 +62,7 @@ function tests_with_normalization { mkdir -p phi-normalized cd phi - PHI_FILES="$(find -name '*.phi' -not -path '.eoc/**')" + PHI_FILES="$(find . -name '*.phi' -not -path '.eoc/**')" for f in $PHI_FILES; do destination="../phi-normalized/$f" mkdir -p $(dirname $destination) From bf2b3f1fd77d51dd3a30882b3295d6d28001a228 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 10:32:05 +0300 Subject: [PATCH 58/70] feat: list all eo tests --- pipeline/config.yaml | 83 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/pipeline/config.yaml b/pipeline/config.yaml index 33d6b3e60..592b3fd05 100644 --- a/pipeline/config.yaml +++ b/pipeline/config.yaml @@ -3,17 +3,78 @@ sets: - source: eo/eo-runtime/src/test/eo/org/eolang/as-phi-tests.eo yaml: pipeline/yaml/as-phi-tests.yaml destination: pipeline/eo/as-phi-tests.eo - programs: - - prints-itself - - prints-itself-to-console - source: eo/eo-runtime/src/test/eo/org/eolang/bool-tests.eo yaml: pipeline/yaml/bool-tests.yaml destination: pipeline/eo/bool-tests.eo - programs: - - compares-two-bools - - compares-two-different-types - - forks-on-condition - - iterates-over-simple-counter - - compares-bool-to-bytes - - compares-bool-to-string - - compares-bool-to-bytes-reverse +- source: eo/eo-runtime/src/test/eo/org/eolang/bytes-tests.eo + yaml: pipeline/yaml/bytes-tests.yaml + destination: pipeline/eo/bytes-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/cage-tests.eo + yaml: pipeline/yaml/cage-tests.yaml + destination: pipeline/eo/cage-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/cti-test.eo + yaml: pipeline/yaml/cti-test.yaml + destination: pipeline/eo/cti-test.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/float-tests.eo + yaml: pipeline/yaml/float-tests.yaml + destination: pipeline/eo/float-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/goto-tests.eo + yaml: pipeline/yaml/goto-tests.yaml + destination: pipeline/eo/goto-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/heap-tests.eo + yaml: pipeline/yaml/heap-tests.yaml + destination: pipeline/eo/heap-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/int-tests.eo + yaml: pipeline/yaml/int-tests.yaml + destination: pipeline/eo/int-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/memory-tests.eo + yaml: pipeline/yaml/memory-tests.yaml + destination: pipeline/eo/memory-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/nan-tests.eo + yaml: pipeline/yaml/nan-tests.yaml + destination: pipeline/eo/nan-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/negative-infinity-tests.eo + yaml: pipeline/yaml/negative-infinity-tests.yaml + destination: pipeline/eo/negative-infinity-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/nop-tests.eo + yaml: pipeline/yaml/nop-tests.yaml + destination: pipeline/eo/nop-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/positive-infinity-tests.eo + yaml: pipeline/yaml/positive-infinity-tests.yaml + destination: pipeline/eo/positive-infinity-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/ram-tests.eo + yaml: pipeline/yaml/ram-tests.yaml + destination: pipeline/eo/ram-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/runtime-tests.eo + yaml: pipeline/yaml/runtime-tests.yaml + destination: pipeline/eo/runtime-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/rust-tests.eo + yaml: pipeline/yaml/rust-tests.yaml + destination: pipeline/eo/rust-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/seq-tests.eo + yaml: pipeline/yaml/seq-tests.yaml + destination: pipeline/eo/seq-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/string-tests.eo + yaml: pipeline/yaml/string-tests.yaml + destination: pipeline/eo/string-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/switch-tests.eo + yaml: pipeline/yaml/switch-tests.yaml + destination: pipeline/eo/switch-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/try-tests.eo + yaml: pipeline/yaml/try-tests.yaml + destination: pipeline/eo/try-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo + yaml: pipeline/yaml/tuple-tests.yaml + destination: pipeline/eo/tuple-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/unit-tests.eo + yaml: pipeline/yaml/unit-tests.yaml + destination: pipeline/eo/unit-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/io/stdout-tests.eo + yaml: pipeline/stdout-tests.yaml + destination: pipeline/eo/io/stdout-tests.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo + yaml: pipeline/tupled-stdout-test.yaml + destination: pipeline/eo/io/tupled-stdout-test.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo + yaml: pipeline/tupled-stdout.yaml + destination: pipeline/eo/io/tupled-stdout.eo From 776ea1ec26c2759ad2157d81c803196aa0069a34 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 10:52:29 +0300 Subject: [PATCH 59/70] fix: disable some tests --- pipeline/config.yaml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pipeline/config.yaml b/pipeline/config.yaml index 592b3fd05..f9bce5838 100644 --- a/pipeline/config.yaml +++ b/pipeline/config.yaml @@ -45,6 +45,12 @@ sets: - source: eo/eo-runtime/src/test/eo/org/eolang/ram-tests.eo yaml: pipeline/yaml/ram-tests.yaml destination: pipeline/eo/ram-tests.eo + programs: + - writes-and-slice-ram + - writes-integer-to-ram + - several-slices-ram + - intersection-writes-in-ram + # - slice-chain - source: eo/eo-runtime/src/test/eo/org/eolang/runtime-tests.eo yaml: pipeline/yaml/runtime-tests.yaml destination: pipeline/eo/runtime-tests.eo @@ -69,12 +75,12 @@ sets: - source: eo/eo-runtime/src/test/eo/org/eolang/unit-tests.eo yaml: pipeline/yaml/unit-tests.yaml destination: pipeline/eo/unit-tests.eo -- source: eo/eo-runtime/src/test/eo/org/eolang/io/stdout-tests.eo - yaml: pipeline/stdout-tests.yaml - destination: pipeline/eo/io/stdout-tests.eo -- source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo - yaml: pipeline/tupled-stdout-test.yaml - destination: pipeline/eo/io/tupled-stdout-test.eo -- source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo - yaml: pipeline/tupled-stdout.yaml - destination: pipeline/eo/io/tupled-stdout.eo +# - source: eo/eo-runtime/src/test/eo/org/eolang/io/stdout-tests.eo +# yaml: pipeline/stdout-tests.yaml +# destination: pipeline/eo/io/stdout-tests.eo +# - source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo +# yaml: pipeline/tupled-stdout-test.yaml +# destination: pipeline/eo/io/tupled-stdout-test.eo +# - source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo +# yaml: pipeline/tupled-stdout.yaml +# destination: pipeline/eo/io/tupled-stdout.eo From 0aef90ab8bee65eb43e9c0d67fb1cfc814f99447 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 11:02:53 +0300 Subject: [PATCH 60/70] feat: optional "programs" in config --- scripts/transform-eo-tests/app/Main.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/transform-eo-tests/app/Main.hs b/scripts/transform-eo-tests/app/Main.hs index 16e58a46d..ef939fe82 100644 --- a/scripts/transform-eo-tests/app/Main.hs +++ b/scripts/transform-eo-tests/app/Main.hs @@ -32,29 +32,32 @@ main = withUtf8 do config <- decodeFileThrow @_ @TestConfig (testDir "config.yaml") createDirectoryIfMissing True config.yamlDirectory forM_ config.sets $ \set -> do - test@Test{source, meta, license} <- parseTest set.source - let programs = filter (\x -> x.name `elem` set.programs) test.programs + test@Test{source, meta} <- parseTest set.source + let programs = + maybe + test.programs + (\programs' -> filter (\x -> x.name `elem` programs') test.programs) + set.programs testContent = TestContent{..} -- write yaml let target = set.yaml targetTmp = target <.> ".tmp" createDirectoryIfMissing True (takeDirectory target) - writeFile target license encodeFile targetTmp testContent readFile targetTmp >>= appendFile target removeFile targetTmp -- write eo createDirectoryIfMissing True (takeDirectory set.destination) - writeFile set.destination (license <> meta) + writeFile set.destination meta forM_ programs (\x -> appendFile set.destination x.text) data TestSet = TestSet { source :: FilePath , yaml :: FilePath , destination :: FilePath - , programs :: [String] + , programs :: Maybe [String] } deriving (Show, Generic, FromJSON) From 6c3fdffc94a74d4fa3e38806ff5e842442accffe Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 12:03:17 +0300 Subject: [PATCH 61/70] fix: disable some tests --- pipeline/config.yaml | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/pipeline/config.yaml b/pipeline/config.yaml index f9bce5838..60a7a1986 100644 --- a/pipeline/config.yaml +++ b/pipeline/config.yaml @@ -6,6 +6,7 @@ sets: - source: eo/eo-runtime/src/test/eo/org/eolang/bool-tests.eo yaml: pipeline/yaml/bool-tests.yaml destination: pipeline/eo/bool-tests.eo + enable: false - source: eo/eo-runtime/src/test/eo/org/eolang/bytes-tests.eo yaml: pipeline/yaml/bytes-tests.yaml destination: pipeline/eo/bytes-tests.eo @@ -42,21 +43,24 @@ sets: - source: eo/eo-runtime/src/test/eo/org/eolang/positive-infinity-tests.eo yaml: pipeline/yaml/positive-infinity-tests.yaml destination: pipeline/eo/positive-infinity-tests.eo + exclude: + - float-equal-to-nan-and-infinites-is-false-highload - source: eo/eo-runtime/src/test/eo/org/eolang/ram-tests.eo yaml: pipeline/yaml/ram-tests.yaml destination: pipeline/eo/ram-tests.eo - programs: - - writes-and-slice-ram - - writes-integer-to-ram - - several-slices-ram - - intersection-writes-in-ram - # - slice-chain + exclude: + - slice-chain - source: eo/eo-runtime/src/test/eo/org/eolang/runtime-tests.eo yaml: pipeline/yaml/runtime-tests.yaml destination: pipeline/eo/runtime-tests.eo + exclude: + - compiles-correctly-with-long-duplicate-names + - constant-defends-against-side-effects + - takes-object-id-from-abstract-empty - source: eo/eo-runtime/src/test/eo/org/eolang/rust-tests.eo yaml: pipeline/yaml/rust-tests.yaml destination: pipeline/eo/rust-tests.eo + enable: false - source: eo/eo-runtime/src/test/eo/org/eolang/seq-tests.eo yaml: pipeline/yaml/seq-tests.yaml destination: pipeline/eo/seq-tests.eo @@ -66,6 +70,9 @@ sets: - source: eo/eo-runtime/src/test/eo/org/eolang/switch-tests.eo yaml: pipeline/yaml/switch-tests.yaml destination: pipeline/eo/switch-tests.eo + exclude: + - switch-complex-case + - switch-simple-case - source: eo/eo-runtime/src/test/eo/org/eolang/try-tests.eo yaml: pipeline/yaml/try-tests.yaml destination: pipeline/eo/try-tests.eo @@ -75,12 +82,15 @@ sets: - source: eo/eo-runtime/src/test/eo/org/eolang/unit-tests.eo yaml: pipeline/yaml/unit-tests.yaml destination: pipeline/eo/unit-tests.eo -# - source: eo/eo-runtime/src/test/eo/org/eolang/io/stdout-tests.eo -# yaml: pipeline/stdout-tests.yaml -# destination: pipeline/eo/io/stdout-tests.eo -# - source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo -# yaml: pipeline/tupled-stdout-test.yaml -# destination: pipeline/eo/io/tupled-stdout-test.eo -# - source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo -# yaml: pipeline/tupled-stdout.yaml -# destination: pipeline/eo/io/tupled-stdout.eo +- source: eo/eo-runtime/src/test/eo/org/eolang/io/stdout-tests.eo + yaml: pipeline/stdout-tests.yaml + destination: pipeline/eo/io/stdout-tests.eo + enable: false +- source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo + yaml: pipeline/tupled-stdout-test.yaml + destination: pipeline/eo/io/tupled-stdout-test.eo + enable: false +- source: eo/eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo + yaml: pipeline/tupled-stdout.yaml + destination: pipeline/eo/io/tupled-stdout.eo + enable: false From af3170493b20b15e7a1c40abdf51506126342c8b Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 12:03:33 +0300 Subject: [PATCH 62/70] fix: log message --- scripts/pipeline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 3d1505ea8..e5971d932 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -88,7 +88,7 @@ function tests_with_normalization { cd .. - printf "\nTest EO\n\n" + printf "\nTest EO with normalization\n\n" mkdir -p eo-normalized cd eo-normalized From 560ab4929835d2b45b7e7edb62554b5e9daf7ca6 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 12:04:57 +0300 Subject: [PATCH 63/70] feat: support optional tests --- scripts/transform-eo-tests/app/Main.hs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/scripts/transform-eo-tests/app/Main.hs b/scripts/transform-eo-tests/app/Main.hs index ef939fe82..5fa0cbb26 100644 --- a/scripts/transform-eo-tests/app/Main.hs +++ b/scripts/transform-eo-tests/app/Main.hs @@ -16,6 +16,7 @@ module Main (main) where import Control.Monad import Data.Function ((&)) import Data.Functor ((<&>)) +import Data.Maybe (fromMaybe) import Data.String (IsString (..)) import Data.Text qualified as T import Data.Yaml (FromJSON, Parser, ToJSON (..), Value (String), decodeFileThrow, encodeFile) @@ -31,13 +32,11 @@ main = withUtf8 do let testDir = "pipeline" config <- decodeFileThrow @_ @TestConfig (testDir "config.yaml") createDirectoryIfMissing True config.yamlDirectory - forM_ config.sets $ \set -> do + forM_ (filter (fromMaybe True . (.enable)) config.sets) $ \set -> do test@Test{source, meta} <- parseTest set.source - let programs = - maybe - test.programs - (\programs' -> filter (\x -> x.name `elem` programs') test.programs) - set.programs + let exclude = fromMaybe [] set.exclude + include = fromMaybe (test.programs <&> (.name)) set.include & filter (`notElem` exclude) + programs = filter (\x -> x.name `elem` include) test.programs testContent = TestContent{..} -- write yaml @@ -57,7 +56,19 @@ data TestSet = TestSet { source :: FilePath , yaml :: FilePath , destination :: FilePath - , programs :: Maybe [String] + , include :: Maybe [String] + -- ^ + -- Program names to include. + -- + -- `Nothing` is equivalent to all programs. + , exclude :: Maybe [String] + -- ^ + -- Program names to exclude + -- + -- `Nothing` is equivalent to no programs. + , enable :: Maybe Bool + -- ^ + -- Whether to enable this test set. } deriving (Show, Generic, FromJSON) From 932822d797fe090fb4f0be7583567f73a1b6047e Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 12:20:12 +0300 Subject: [PATCH 64/70] fix: disable tests that fail on windows --- pipeline/config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pipeline/config.yaml b/pipeline/config.yaml index 60a7a1986..567ff2503 100644 --- a/pipeline/config.yaml +++ b/pipeline/config.yaml @@ -73,6 +73,12 @@ sets: exclude: - switch-complex-case - switch-simple-case + # fails on windows + - switch-strings-case + # fails on windows + - switch-with-all-false-cases + # fails on windows + - switch-with-several-true-cases - source: eo/eo-runtime/src/test/eo/org/eolang/try-tests.eo yaml: pipeline/yaml/try-tests.yaml destination: pipeline/eo/try-tests.eo From 717ad9c0f7915a75b28e0357b01165912e2e6eb4 Mon Sep 17 00:00:00 2001 From: Danila Danko <48378098+deemp@users.noreply.github.com> Date: Thu, 7 Mar 2024 17:33:35 +0300 Subject: [PATCH 65/70] fix: update EO to 0.35.8 --- scripts/pipeline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index e5971d932..6f8bc15a1 100755 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -5,7 +5,7 @@ if ! [ -d node_modules ]; then npm i; fi export LC_ALL=C.UTF-8 shopt -s expand_aliases -EO="0.35.6" +EO="0.35.8" alias eo="npx eoc --parser=${EO}" shopt -s extglob From 13aa9f18d1b4d4991c1a9f93b402c9881294c8dc Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 12:49:34 +0300 Subject: [PATCH 66/70] fix: switch eo to 0.35.6 --- eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo b/eo index 9759a327a..a2be0ace7 160000 --- a/eo +++ b/eo @@ -1 +1 @@ -Subproject commit 9759a327a2609ae91c882412e495367dded234bd +Subproject commit a2be0ace7eb895d1da4aa7b4a84155d2b149cdac From d229554a39f61d2b260eb3074ab5521fd19cb1ea Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Tue, 5 Mar 2024 23:16:13 +0300 Subject: [PATCH 67/70] Add support for comments in Phi syntax --- eo-phi-normalizer/grammar/EO/Phi/Syntax.cf | 3 + .../src/Language/EO/Phi/Syntax/Doc.txt | 208 +++++++++--------- .../src/Language/EO/Phi/Syntax/Lex.x | 6 + 3 files changed, 113 insertions(+), 104 deletions(-) diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf index ba0a995a8..92f83e4e1 100644 --- a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf @@ -4,6 +4,9 @@ -- -- This is a non-ambiguous grammar for φ-programs. +comment "//" ; +comment "/*" "*/" ; + token Bytes ({"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] {"-"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ({"-"} ["0123456789ABCDEF"] ["0123456789ABCDEF"])+) ; token Function upper (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; token LabelId lower (char - [" \r\n\t,.|':;!?][}{)(⟧⟦"])* ; 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 8d38f607b..9f95a856f 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt @@ -1,104 +1,104 @@ -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*````` - -MetaId literals are recognized by the regular expression -`````'!' (char - [" - !'(),-.:;?[]{|}⟦⟧"])*````` - -MetaFunctionName literals are recognized by the regular expression -`````'@' (char - [" - !'(),-.:;?[]{|}⟦⟧"])*````` - - -===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// - | | **|** | ``Φ`` - | | **|** | ``ξ`` - | | **|** | ``⊥`` - | | **|** | //MetaId// - | | **|** | //MetaFunctionName// ``(`` //Object// ``)`` - | //Binding// | -> | //Attribute// ``↦`` //Object// - | | **|** | //Attribute// ``↦`` ``∅`` - | | **|** | ``Δ`` ``⤍`` //Bytes// - | | **|** | ``λ`` ``⤍`` //Function// - | | **|** | //MetaId// - | //[Binding]// | -> | **eps** - | | **|** | //Binding// - | | **|** | //Binding// ``,`` //[Binding]// - | //Attribute// | -> | ``φ`` - | | **|** | ``ρ`` - | | **|** | ``σ`` - | | **|** | ``ν`` - | | **|** | //LabelId// - | | **|** | //AlphaIndex// - | | **|** | //MetaId// - | //RuleAttribute// | -> | //Attribute// - | | **|** | ``Δ`` - | | **|** | ``λ`` - | //PeeledObject// | -> | //ObjectHead// //[ObjectAction]// - | //ObjectHead// | -> | ``⟦`` //[Binding]// ``⟧`` - | | **|** | ``Φ`` - | | **|** | ``ξ`` - | | **|** | ``⊥`` - | //ObjectAction// | -> | ``(`` //[Binding]// ``)`` - | | **|** | ``.`` //Attribute// - | //[ObjectAction]// | -> | **eps** - | | **|** | //ObjectAction// //[ObjectAction]// - - - -%% File generated by the BNF Converter (bnfc 2.9.5). +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*````` + +MetaId literals are recognized by the regular expression +`````'!' (char - [" + !'(),-.:;?[]{|}⟦⟧"])*````` + +MetaFunctionName literals are recognized by the regular expression +`````'@' (char - [" + !'(),-.:;?[]{|}⟦⟧"])*````` + + +===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=== +Single-line comments begin with //.Multiple-line comments are enclosed with /* and */. + +==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// + | | **|** | ``Φ`` + | | **|** | ``ξ`` + | | **|** | ``⊥`` + | | **|** | //MetaId// + | | **|** | //MetaFunctionName// ``(`` //Object// ``)`` + | //Binding// | -> | //Attribute// ``↦`` //Object// + | | **|** | //Attribute// ``↦`` ``∅`` + | | **|** | ``Δ`` ``⤍`` //Bytes// + | | **|** | ``λ`` ``⤍`` //Function// + | | **|** | //MetaId// + | //[Binding]// | -> | **eps** + | | **|** | //Binding// + | | **|** | //Binding// ``,`` //[Binding]// + | //Attribute// | -> | ``φ`` + | | **|** | ``ρ`` + | | **|** | ``σ`` + | | **|** | ``ν`` + | | **|** | //LabelId// + | | **|** | //AlphaIndex// + | | **|** | //MetaId// + | //RuleAttribute// | -> | //Attribute// + | | **|** | ``Δ`` + | | **|** | ``λ`` + | //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 080e6b0a0..bd6dba3bc 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x @@ -32,6 +32,12 @@ $u = [. \n] -- universal: any character :- +-- Line comment "//" +"//" [.]* ; + +-- Block comment "/*" "*/" +\/ \* [$u # \*]* \* ([$u # [\* \/]] [$u # \*]* \* | \*)* \/ ; + -- Whitespace (skipped) $white+ ; From 343a7c16dcbfcf1d4e53b745b02f89e5052a8a95 Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Wed, 6 Mar 2024 18:51:37 +0300 Subject: [PATCH 68/70] Add support for empty delta bindings --- eo-phi-normalizer/grammar/EO/Phi/Syntax.cf | 11 ++++++----- eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs | 1 + eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt | 1 + eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y | 1 + eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf index 92f83e4e1..1a2fb7e90 100644 --- a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf @@ -25,11 +25,12 @@ Termination. Object ::= "⊥" ; MetaObject. Object ::= MetaId ; MetaFunction. Object ::= MetaFunctionName "(" Object ")" ; -AlphaBinding. Binding ::= Attribute "↦" Object ; -EmptyBinding. Binding ::= Attribute "↦" "∅" ; -DeltaBinding. Binding ::= "Δ" "⤍" Bytes ; -LambdaBinding. Binding ::= "λ" "⤍" Function ; -MetaBindings. Binding ::= MetaId ; +AlphaBinding. Binding ::= Attribute "↦" Object ; +EmptyBinding. Binding ::= Attribute "↦" "∅" ; +DeltaBinding. Binding ::= "Δ" "⤍" Bytes ; +DeltaEmptyBinding. Binding ::= "Δ" "⤍" "∅" ; +LambdaBinding. Binding ::= "λ" "⤍" Function ; +MetaBindings. Binding ::= MetaId ; separator Binding "," ; Phi. Attribute ::= "φ" ; -- decoratee object 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 3756fa6d0..f39edb94e 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs @@ -33,6 +33,7 @@ data Binding = AlphaBinding Attribute Object | EmptyBinding Attribute | DeltaBinding Bytes + | DeltaEmptyBinding | LambdaBinding Function | MetaBindings MetaId deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) 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 9f95a856f..171b18a3e 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt @@ -74,6 +74,7 @@ All other symbols are terminals. | //Binding// | -> | //Attribute// ``↦`` //Object// | | **|** | //Attribute// ``↦`` ``∅`` | | **|** | ``Δ`` ``⤍`` //Bytes// + | | **|** | ``Δ`` ``⤍`` ``∅`` | | **|** | ``λ`` ``⤍`` //Function// | | **|** | //MetaId// | //[Binding]// | -> | **eps** 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 144354aa0..3e6ba3918 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y @@ -108,6 +108,7 @@ Binding : Attribute '↦' Object { Language.EO.Phi.Syntax.Abs.AlphaBinding $1 $3 } | Attribute '↦' '∅' { Language.EO.Phi.Syntax.Abs.EmptyBinding $1 } | 'Δ' '⤍' Bytes { Language.EO.Phi.Syntax.Abs.DeltaBinding $3 } + | 'Δ' '⤍' '∅' { Language.EO.Phi.Syntax.Abs.DeltaEmptyBinding } | 'λ' '⤍' Function { Language.EO.Phi.Syntax.Abs.LambdaBinding $3 } | MetaId { Language.EO.Phi.Syntax.Abs.MetaBindings $1 } 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 112ffea63..48217c459 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs @@ -169,6 +169,7 @@ instance Print Language.EO.Phi.Syntax.Abs.Binding where Language.EO.Phi.Syntax.Abs.AlphaBinding attribute object -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), prt 0 object]) Language.EO.Phi.Syntax.Abs.EmptyBinding attribute -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), doc (showString "\8709")]) Language.EO.Phi.Syntax.Abs.DeltaBinding bytes -> prPrec i 0 (concatD [doc (showString "\916"), doc (showString "\10509"), prt 0 bytes]) + Language.EO.Phi.Syntax.Abs.DeltaEmptyBinding -> prPrec i 0 (concatD [doc (showString "\916"), doc (showString "\10509"), doc (showString "\8709")]) Language.EO.Phi.Syntax.Abs.LambdaBinding function -> prPrec i 0 (concatD [doc (showString "\955"), doc (showString "\10509"), prt 0 function]) Language.EO.Phi.Syntax.Abs.MetaBindings metaid -> prPrec i 0 (concatD [prt 0 metaid]) From 24a9310f44715a58ab5b239dfb477589c8fa4fc1 Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Wed, 6 Mar 2024 19:00:30 +0300 Subject: [PATCH 69/70] Add pattern matches for DeltaEmptyBinding --- eo-phi-normalizer/src/Language/EO/Phi/Metrics/Collect.hs | 2 +- eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs | 3 +++ eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs | 3 +++ eo-phi-normalizer/test/Language/EO/Rules/PhiPaperSpec.hs | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Metrics/Collect.hs b/eo-phi-normalizer/src/Language/EO/Phi/Metrics/Collect.hs index 2e0d3630f..68365d006 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Metrics/Collect.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Metrics/Collect.hs @@ -68,7 +68,7 @@ count x = length . filter x -- 1 countDataless :: (Num a) => [Binding] -> a countDataless bindings = - let countDeltas = count (\case DeltaBinding _ -> True; _ -> False) + let countDeltas = count (\case DeltaBinding _ -> True; DeltaEmptyBinding -> True; _ -> False) nestedBindings = concatMap (\case AlphaBinding _ (Formation bindings') -> bindings'; _ -> []) bindings deltas = countDeltas (bindings <> nestedBindings) in if deltas == 0 then 1 else 0 diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs index 1b9eead63..26677136d 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs @@ -96,6 +96,7 @@ withSubObjectBinding f ctx = \case AlphaBinding a obj -> AlphaBinding a <$> withSubObject f (ctx{currentAttr = a}) obj EmptyBinding{} -> [] DeltaBinding{} -> [] + DeltaEmptyBinding{} -> [] LambdaBinding{} -> [] MetaBindings _ -> [] @@ -139,6 +140,7 @@ bindingSize = \case AlphaBinding _attr obj -> objectSize obj EmptyBinding _attr -> 1 DeltaBinding _bytes -> 1 + DeltaEmptyBinding -> 1 LambdaBinding _lam -> 1 MetaBindings{} -> 1 -- should be impossible @@ -174,6 +176,7 @@ equalBindings bindings1 bindings2 = and (zipWith equalBinding (sortOn attr bindi attr (AlphaBinding a _) = a attr (EmptyBinding a) = a attr (DeltaBinding _) = Label (LabelId "Δ") + attr DeltaEmptyBinding = Label (LabelId "Δ") attr (LambdaBinding _) = Label (LabelId "λ") attr (MetaBindings metaId) = MetaAttr metaId diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs index 8a4263a55..82c5a3928 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs @@ -131,6 +131,7 @@ bindingHasMetavars :: Binding -> Bool bindingHasMetavars (AlphaBinding attr obj) = attrHasMetavars attr || objectHasMetavars obj bindingHasMetavars (EmptyBinding attr) = attrHasMetavars attr bindingHasMetavars (DeltaBinding _) = False +bindingHasMetavars DeltaEmptyBinding = False bindingHasMetavars (LambdaBinding _) = False bindingHasMetavars (MetaBindings _) = True @@ -170,6 +171,7 @@ hasAttr attr = any (isAttr attr) isAttr (ObjectAttr a) (AlphaBinding a' _) = a == a' isAttr (ObjectAttr a) (EmptyBinding a') = a == a' isAttr DeltaAttr (DeltaBinding _) = True + isAttr DeltaAttr DeltaEmptyBinding = True isAttr LambdaAttr (LambdaBinding _) = True isAttr _ _ = False @@ -243,6 +245,7 @@ applySubstBinding subst@Subst{..} = \case EmptyBinding a -> [EmptyBinding (applySubstAttr subst a)] DeltaBinding bytes -> [DeltaBinding (coerce bytes)] + DeltaEmptyBinding -> [DeltaEmptyBinding] LambdaBinding bytes -> [LambdaBinding (coerce bytes)] b@(MetaBindings m) -> fromMaybe [b] (lookup m bindingsMetas) diff --git a/eo-phi-normalizer/test/Language/EO/Rules/PhiPaperSpec.hs b/eo-phi-normalizer/test/Language/EO/Rules/PhiPaperSpec.hs index a8fb49300..34ec011c7 100644 --- a/eo-phi-normalizer/test/Language/EO/Rules/PhiPaperSpec.hs +++ b/eo-phi-normalizer/test/Language/EO/Rules/PhiPaperSpec.hs @@ -70,6 +70,7 @@ instance Arbitrary Binding where return (AlphaBinding attr obj) , DeltaBinding <$> arbitrary , LambdaBinding <$> arbitrary + , pure DeltaEmptyBinding ] shrink (AlphaBinding VTX _) = [] -- do not shrink vertex bindings shrink (AlphaBinding attr obj) = AlphaBinding attr <$> shrink obj From 9a31076797f2ada9f091fb0999b94a398837f547 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 7 Mar 2024 21:15:28 +0300 Subject: [PATCH 70/70] fix: update eo submodule to 0.35.8 --- eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo b/eo index a2be0ace7..3650885c0 160000 --- a/eo +++ b/eo @@ -1 +1 @@ -Subproject commit a2be0ace7eb895d1da4aa7b4a84155d2b149cdac +Subproject commit 3650885c0925ad4a17b13c54d9a875fccf577817