Skip to content

Commit

Permalink
Merge pull request #426 from objectionary/406-support-enablingdisabli…
Browse files Browse the repository at this point in the history
…ng-particular-atoms

406 support enabling/disabling particular atoms
  • Loading branch information
fizruk authored Jul 19, 2024
2 parents d2f83a0 + 32be6c9 commit c2ce147
Show file tree
Hide file tree
Showing 46 changed files with 2,046 additions and 190 deletions.
2 changes: 1 addition & 1 deletion eo
Submodule eo updated 49 files
+19 −32 .github/workflows/copyrights.yml
+1 −1 .github/workflows/ebnf.yml
+1 −1 .github/workflows/loc-badge.yml
+1 −1 .github/workflows/sonar.yml
+43 −0 .github/workflows/trufflehog-oss.yml
+2 −2 eo-maven-plugin/README.md
+7 −7 eo-maven-plugin/pom.xml
+74 −19 eo-maven-plugin/src/main/java/org/eolang/maven/PhiMojo.java
+12 −2 eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java
+22 −7 eo-maven-plugin/src/main/java/org/eolang/maven/UnphiMojo.java
+9 −1 eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojo.java
+2 −2 eo-maven-plugin/src/main/resources/org/eolang/maven/add_rust/add_rust.xsl
+62 −0 eo-maven-plugin/src/main/resources/org/eolang/maven/phi/incorrect-inners.xsl
+0 −1 eo-maven-plugin/src/main/resources/org/eolang/maven/phi/to-phi.xsl
+72 −0 eo-maven-plugin/src/main/resources/org/eolang/maven/unphi/atoms-with-bound-attrs.xsl
+46 −0 eo-maven-plugin/src/main/resources/org/eolang/maven/unphi/wrap-bytes.xsl
+2 −0 eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java
+75 −3 eo-maven-plugin/src/test/java/org/eolang/maven/PhiMojoTest.java
+36 −0 eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java
+13 −17 eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java
+6 −0 eo-maven-plugin/src/test/java/org/eolang/maven/log/CaptureLogs.java
+0 −0 eo-maven-plugin/src/test/resources/org/eolang/maven/binarize/add_rust/detects-rust-code-with-wide-string.yaml
+275 −0 ...lugin/src/test/resources/org/eolang/maven/binarize/add_rust/detects-rust-dependencies-with-wide-string.yaml
+129 −0 eo-maven-plugin/src/test/resources/org/eolang/maven/phi/xmir/B.xmir
+1 −37 eo-maven-plugin/src/test/resources/org/eolang/maven/phi/xmir/OriginalException.xmir
+0 −30 eo-maven-plugin/src/test/resources/org/eolang/maven/phi/xmir/SomeException.xmir
+0 −40 eo-maven-plugin/src/test/resources/org/eolang/maven/phi/xmir/Top$TopInnerInstance.xmir
+0 −25 eo-maven-plugin/src/test/resources/org/eolang/maven/phi/xmir/Top$TopInnerStatic.xmir
+15 −4 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/atoms.yaml
+7 −23 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/bindings.yaml
+38 −0 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/delta-in-formation.yaml
+2 −5 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/empty-bytes.yaml
+47 −0 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/normalized-atom.yaml
+2 −4 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/one-byte.yaml
+1 −5 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/package.yaml
+3 −5 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/specials.yaml
+36 −0 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/termination.yaml
+2 −3 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/with-anonym-abstract.yaml
+2 −8 eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/with-data.yaml
+1 −1 eo-parser/pom.xml
+12 −2 eo-parser/src/main/java/org/eolang/parser/XePhiListener.java
+1 −1 eo-runtime/pom.xml
+18 −1 eo-runtime/src/main/eo/org/eolang/seq.eo
+0 −91 eo-runtime/src/main/java/EOorg/EOeolang/EOseq.java
+68 −0 eo-runtime/src/test/eo/org/eolang/rust-tests.eo
+18 −0 eo-runtime/src/test/eo/org/eolang/seq-tests.eo
+0 −87 eo-runtime/src/test/java/EOorg/EOeolang/EOseqTest.java
+0 −6 eo-runtime/src/test/java/org/eolang/SnippetTestCase.java
+3 −3 pom.xml
65 changes: 52 additions & 13 deletions eo-phi-normalizer/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import Language.EO.Phi.Dependencies
import Language.EO.Phi.Metrics.Collect as Metrics (getProgramMetrics)
import Language.EO.Phi.Metrics.Data as Metrics (ProgramMetrics (..), splitPath)
import Language.EO.Phi.Pipeline.Config
import Language.EO.Phi.Pipeline.Dataize.PrintConfigs
import Language.EO.Phi.Pipeline.EOTests.PrepareTests (prepareTests)
import Language.EO.Phi.Report.Data (makeProgramReport, makeReport)
import Language.EO.Phi.Report.Html (reportCSS, reportJS, toStringReport)
Expand Down Expand Up @@ -86,6 +87,8 @@ data CLI'DataizePhi = CLI'DataizePhi
, asPackage :: Bool
, minimizeStuckTerms :: Bool
, wrapRawBytes :: Bool
, disabledAtomNames :: [String]
, enabledAtomNames :: [String]
}
deriving (Show)

Expand All @@ -101,23 +104,30 @@ newtype CLI'ReportPhi = CLI'ReportPhi
}
deriving (Show)

newtype CLI'PreparePipelineTests = CLI'PreparePipelineTests
{ configFile :: FilePath
}
data CLI'Pipeline
= CLI'Pipeline'PrepareTests
{ configFile :: FilePath
}
| CLI'Pipeline'PrintDataizeConfigs
{ configFile :: FilePath
, phiPrefixesToStrip :: [FilePath]
, singleLine :: Bool
}
deriving (Show)

data CLI
= CLI'TransformPhi' CLI'TransformPhi
| CLI'DataizePhi' CLI'DataizePhi
| CLI'MetricsPhi' CLI'MetricsPhi
| CLI'ReportPhi' CLI'ReportPhi
| CLI'PreparePipelineTests' CLI'PreparePipelineTests
| CLI'Pipeline' CLI'Pipeline
deriving (Show)

data MetavarName = MetavarName
{ file :: String
, int :: String
, path :: String
, atomName :: String
}

metavarName :: MetavarName
Expand All @@ -126,12 +136,14 @@ metavarName =
{ file = "FILE"
, int = "INT"
, path = "PATH"
, atomName = "ATOM_NAME"
}

data Metavar a b = Metavar
{ file :: Mod a b
, int :: Mod a b
, path :: Mod a b
, atomName :: Mod a b
}

metavar :: (HasMetavar a) => Metavar a b
Expand All @@ -140,6 +152,7 @@ metavar =
{ file = Optparse.metavar metavarName.file
, int = Optparse.metavar metavarName.int
, path = Optparse.metavar metavarName.path
, atomName = Optparse.metavar metavarName.atomName
}

newtype OptionName = OptionName
Expand Down Expand Up @@ -196,7 +209,9 @@ data CommandParser = CommandParser
, transform :: Parser CLI'TransformPhi
, dataize :: Parser CLI'DataizePhi
, report :: Parser CLI'ReportPhi
, preparePipelineTests :: Parser CLI'PreparePipelineTests
, pipeline :: Parser CLI'Pipeline
, pipelinePrepareTests :: Parser CLI'Pipeline
, pipelinePrintDataizeConfigs :: Parser CLI'Pipeline
}

commandParser :: CommandParser
Expand Down Expand Up @@ -236,20 +251,34 @@ commandParser =
latex <- latexSwitch
asPackage <- asPackageSwitch
minimizeStuckTerms <- minimizeStuckTermsSwitch
disabledAtomNames <- many $ strOption (long "disable-atom" <> metavar.atomName <> help "Disable a particular atom by its name.")
enabledAtomNames <- many $ strOption (long "enable-atom" <> metavar.atomName <> help "Enable a particular atom by its name.")
pure CLI'DataizePhi{..}
report = do
configFile <- strOption (long "config" <> short 'c' <> metavar.file <> help [fmt|A report configuration {metavarName.file}.|])
pure CLI'ReportPhi{..}
preparePipelineTests = do
pipelinePrepareTests = do
configFile <- strOption (long "config" <> short 'c' <> metavar.file <> help [fmt|A pipeline tests configuration {metavarName.file}.|])
pure CLI'Pipeline'PrepareTests{..}
pipelinePrintDataizeConfigs = do
configFile <- strOption (long "config" <> short 'c' <> metavar.file <> help [fmt|A pipeline tests configuration {metavarName.file}.|])
pure CLI'PreparePipelineTests{..}
phiPrefixesToStrip <- many $ strOption (long "strip-phi-prefix" <> short 'p' <> metavar.atomName <> help "Remove prefixes in PHI file paths.")
singleLine <- switch (long "single-line" <> short 'l' <> help [fmt|Output configs on an single line.|])
pure CLI'Pipeline'PrintDataizeConfigs{..}
pipeline =
hsubparser
( command commandNames.pipelinePrepareTests commandParserInfo.pipelinePrepareTests
<> command commandNames.pipelinePrintDataizeConfigs commandParserInfo.pipelinePrintDataizeConfigs
)

data CommandParserInfo = CommandParserInfo
{ metrics :: ParserInfo CLI
, transform :: ParserInfo CLI
, dataize :: ParserInfo CLI
, report :: ParserInfo CLI
, preparePipelineTests :: ParserInfo CLI
, pipeline :: ParserInfo CLI
, pipelinePrepareTests :: ParserInfo CLI'Pipeline
, pipelinePrintDataizeConfigs :: ParserInfo CLI'Pipeline
}

commandParserInfo :: CommandParserInfo
Expand All @@ -259,15 +288,19 @@ commandParserInfo =
, transform = info (CLI'TransformPhi' <$> commandParser.transform) (progDesc "Transform a PHI program.")
, dataize = info (CLI'DataizePhi' <$> commandParser.dataize) (progDesc "Dataize a PHI program.")
, report = info (CLI'ReportPhi' <$> commandParser.report) (progDesc "Generate reports about initial and normalized PHI programs.")
, preparePipelineTests = info (CLI'PreparePipelineTests' <$> commandParser.preparePipelineTests) (progDesc "Prepare EO test files for the pipeline.")
, pipeline = info (CLI'Pipeline' <$> commandParser.pipeline) (progDesc "Run pipeline-related commands.")
, pipelinePrepareTests = info commandParser.pipelinePrepareTests (progDesc "Prepare EO test files for the pipeline.")
, pipelinePrintDataizeConfigs = info commandParser.pipelinePrintDataizeConfigs (progDesc "Print configs for the `normalizer dataize` command.")
}

data CommandNames = CommandNames
{ transform :: String
, metrics :: String
, dataize :: String
, report :: String
, preparePipelineTests :: String
, pipeline :: String
, pipelinePrepareTests :: String
, pipelinePrintDataizeConfigs :: String
}

commandNames :: CommandNames
Expand All @@ -277,7 +310,9 @@ commandNames =
, metrics = "metrics"
, dataize = "dataize"
, report = "report"
, preparePipelineTests = "prepare-pipeline-tests"
, pipeline = "pipeline"
, pipelinePrepareTests = "prepare-tests"
, pipelinePrintDataizeConfigs = "print-dataize-configs"
}

cli :: Parser CLI
Expand All @@ -287,7 +322,7 @@ cli =
<> command commandNames.metrics commandParserInfo.metrics
<> command commandNames.dataize commandParserInfo.dataize
<> command commandNames.report commandParserInfo.report
<> command commandNames.preparePipelineTests commandParserInfo.preparePipelineTests
<> command commandNames.pipeline commandParserInfo.pipeline
)

cliOpts :: ParserInfo CLI
Expand Down Expand Up @@ -528,6 +563,7 @@ main = withUtf8 do
(defaultContext rules (Formation bindingsWithDeps)) -- IMPORTANT: context contains dependencies!
{ minimizeTerms = minimizeStuckTerms
, builtinRules = builtin
, enabledAtomNames = mkEnabledAtomNames disabledAtomNames enabledAtomNames
}
if chain
then do
Expand Down Expand Up @@ -594,6 +630,9 @@ main = withUtf8 do
$ \(path, reportString) -> do
createDirectoryIfMissing True (takeDirectory path)
writeFile path reportString
CLI'PreparePipelineTests' CLI'PreparePipelineTests{..} -> do
CLI'Pipeline' CLI'Pipeline'PrepareTests{..} -> do
config <- decodeFileThrow @_ @PipelineConfig configFile
prepareTests config
CLI'Pipeline' CLI'Pipeline'PrintDataizeConfigs{..} -> do
config <- decodeFileThrow @_ @PipelineConfig configFile
printDataizeConfigs config phiPrefixesToStrip singleLine
14 changes: 14 additions & 0 deletions eo-phi-normalizer/data/0.38.4/org/eolang/as-phi.phi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
org ↦ ⟦
eolang ↦ ⟦
as-phi ↦ ⟦
λ ⤍ Lorg_eolang_as_phi,
x ↦ ∅
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
107 changes: 107 additions & 0 deletions eo-phi-normalizer/data/0.38.4/org/eolang/bytes.phi
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
org ↦ ⟦
eolang ↦ ⟦
bytes ↦ ⟦
Δ ⤍ ∅,
as-bytes ↦ ξ,
eq ↦ ⟦
λ ⤍ Lorg_eolang_bytes_eq,
b ↦ ∅
⟧,
size ↦ ⟦
λ ⤍ Lorg_eolang_bytes_size
⟧,
slice ↦ ⟦
λ ⤍ Lorg_eolang_bytes_slice,
start ↦ ∅,
len ↦ ∅
⟧,
as-string ↦ ⟦
φ ↦ Φ.org.eolang.string(
α0 ↦ ξ.ρ
)
⟧,
as-int ↦ ⟦
φ ↦ ξ.ρ.size.eq(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-08
)
)
).if(
α0 ↦ Φ.org.eolang.int(
α0 ↦ ξ.ρ
),
α1 ↦ Φ.org.eolang.error(
α0 ↦ Φ.org.eolang.string(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 43-61-6E-27-74-20-63-6F-6E-76-65-72-74-20-6E-6F-6E-20-38-20-6C-65-6E-67-74-68-20-62-79-74-65-73-20-74-6F-20-69-6E-74
)
)
)
)
⟧,
as-float ↦ ⟦
φ ↦ ξ.ρ.size.eq(
α0 ↦ Φ.org.eolang.int(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 00-00-00-00-00-00-00-08
)
)
).if(
α0 ↦ Φ.org.eolang.float(
α0 ↦ ξ.ρ
),
α1 ↦ Φ.org.eolang.error(
α0 ↦ Φ.org.eolang.string(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 43-61-6E-27-74-20-63-6F-6E-76-65-72-74-20-6E-6F-6E-20-38-20-6C-65-6E-67-74-68-20-62-79-74-65-73-20-74-6F-20-66-6C-6F-61-74
)
)
)
)
⟧,
and ↦ ⟦
λ ⤍ Lorg_eolang_bytes_and,
b ↦ ∅
⟧,
or ↦ ⟦
λ ⤍ Lorg_eolang_bytes_or,
b ↦ ∅
⟧,
xor ↦ ⟦
λ ⤍ Lorg_eolang_bytes_xor,
b ↦ ∅
⟧,
not ↦ ⟦
λ ⤍ Lorg_eolang_bytes_not
⟧,
left ↦ ⟦
φ ↦ ξ.ρ.right(
α0 ↦ ξ.x.neg
),
x ↦ ∅
⟧,
right ↦ ⟦
λ ⤍ Lorg_eolang_bytes_right,
x ↦ ∅
⟧,
as-bool ↦ ⟦
φ ↦ ξ.ρ.eq(
α0 ↦ Φ.org.eolang.bytes(
Δ ⤍ 01-
)
)
⟧,
concat ↦ ⟦
λ ⤍ Lorg_eolang_bytes_concat,
b ↦ ∅
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
28 changes: 28 additions & 0 deletions eo-phi-normalizer/data/0.38.4/org/eolang/cage.phi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
org ↦ ⟦
eolang ↦ ⟦
cage ↦ ⟦
object ↦ ∅,
new ↦ ξ.φ.self,
φ ↦ ⟦
λ ⤍ Lorg_eolang_cage_φ
⟧,
encaged ↦ ⟦
locator ↦ ∅,
self ↦ ξ,
φ ↦ ⟦
λ ⤍ Lorg_eolang_cage_encaged_φ
⟧,
encage ↦ ⟦
λ ⤍ Lorg_eolang_cage_encaged_encage,
object ↦ ∅
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
16 changes: 16 additions & 0 deletions eo-phi-normalizer/data/0.38.4/org/eolang/cti.phi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
org ↦ ⟦
eolang ↦ ⟦
cti ↦ ⟦
φ ↦ ξ.delegate,
delegate ↦ ∅,
level ↦ ∅,
message ↦ ∅
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
14 changes: 14 additions & 0 deletions eo-phi-normalizer/data/0.38.4/org/eolang/dataized.phi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
org ↦ ⟦
eolang ↦ ⟦
dataized ↦ ⟦
λ ⤍ Lorg_eolang_dataized,
target ↦ ∅
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
14 changes: 14 additions & 0 deletions eo-phi-normalizer/data/0.38.4/org/eolang/error.phi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
org ↦ ⟦
eolang ↦ ⟦
error ↦ ⟦
λ ⤍ Lorg_eolang_error,
message ↦ ∅
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
Loading

6 comments on commit c2ce147

@0pdd
Copy link

@0pdd 0pdd commented on c2ce147 Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 166-b045973b disappeared from eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs), that's why I closed #175. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on c2ce147 Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 213-0fc2ca1f disappeared from .github/workflows/ghc.yml), that's why I closed #249. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on c2ce147 Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 98-3c3fb254 disappeared from .github/workflows/ghc.yml), that's why I closed #250. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on c2ce147 Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 263-2f52bb02 disappeared from scripts/pipeline.sh), that's why I closed #283. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on c2ce147 Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 340-40b07064 discovered in .github/workflows/ghc.yml) and submitted as #437. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0crat
Copy link

@0crat 0crat commented on c2ce147 Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fizruk It is not a good idea to push directly to the default branch master. You've earned -20 points for this: -20 as a basis. Next time, create a new branch, push your changes over there, then make a pull request and merge it. Even if you are flying solo, contributing via pull requests is a good practice. Your running balance is +35.

Please sign in to comment.