From 2bb12b59a20bf20111cf52cb54af8e5445d4f064 Mon Sep 17 00:00:00 2001 From: Christian Krause Date: Fri, 11 Mar 2022 12:12:05 +0100 Subject: [PATCH] submit command extracts a-number --- CHANGELOG.md | 11 +++++++---- README.md | 11 +++++++---- src/commands.cpp | 6 +++--- src/include/commands.hpp | 2 +- src/include/miner.hpp | 2 +- src/main.cpp | 7 +++++-- src/miner.cpp | 9 ++++++++- 7 files changed, 32 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e750c47..bf8681b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,18 @@ To install or update LODA, please follow the [installation instructions](https:/ ## [Unreleased] -### Enhancements - -* Incremental evaluation (IE) partially supports programs with non-commutative updates of output cells. IE is supported for 5200 programs now. -* Store default values in `setup.txt` +## v22.3.11 ### Features * Parallel mining with custom number of instances: `-P ` * Short-hand parameter for b-file output with offset 0: `-b` +* `submit` command extracts A-number from comment in programs + +### Enhancements + +* Incremental evaluation (IE) partially supports programs with non-commutative updates of output cells. IE is supported for 5200 programs now. +* Store default values in `setup.txt` ## v22.2.17 diff --git a/README.md b/README.md index 60712579..4bab7f06 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ To mine programs for OEIS sequences, you can run `loda mine` (single-core) or `l The `loda` command-line tool provides the following commands and options: ``` -Welcome to LODA developer version. More information at https://loda-lang.org +Welcome to LODA developer version. More information at https://loda-lang.org/ Usage: loda @@ -37,9 +37,9 @@ Core Commands: setup Run interactive setup to configure LODA OEIS Commands: - mine Mine programs for OEIS sequences (see -i) + mine Mine programs for OEIS sequences (see -i,-p) check Check a program for an OEIS sequence (see -b) - submit Submit a program for an OEIS sequence + submit [id] Submit a program for an OEIS sequence Targets: Path to a LODA file (file extension: *.asm) @@ -48,12 +48,15 @@ Targets: Options: -t Number of sequence terms (default: 10) - -b Print result in b-file format from a given offset + -b Print result in b-file format from offset 0 + -B Print result in b-file format from a custom offset -s Evaluate program to number of execution steps -c Maximum number of interpreter cycles (no limit: -1) -m Maximum number of used memory cells (no limit: -1) -l Log level (values: debug,info,warn,error,alert) -i Name of miner configuration from miners.json + -p Parallel mining using default number of instances + -P Parallel mining using custom number of instances ``` ### Core Commands diff --git a/src/commands.cpp b/src/commands.cpp index 80da2bb0..03409df1 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -52,7 +52,7 @@ void Commands::help() { std::cout << " check Check a program for an OEIS sequence " "(see -b)" << std::endl; - std::cout << " submit Submit a program for an OEIS sequence" + std::cout << " submit [id] Submit a program for an OEIS sequence" << std::endl; std::cout << std::endl << "Targets:" << std::endl; std::cout @@ -168,10 +168,10 @@ void Commands::mine() { miner.mine(); } -void Commands::submit(const std::string& id, const std::string& path) { +void Commands::submit(const std::string& path, const std::string& id) { initLog(false); Miner miner(settings); - miner.submit(id, path); + miner.submit(path, id); } // hidden commands (only in development versions) diff --git a/src/include/commands.hpp b/src/include/commands.hpp index 008b2aff..de77ddd1 100644 --- a/src/include/commands.hpp +++ b/src/include/commands.hpp @@ -24,7 +24,7 @@ class Commands { void mine(); - void submit(const std::string& id, const std::string& path); + void submit(const std::string& path, const std::string& id); // hidden commands (only in development versions) diff --git a/src/include/miner.hpp b/src/include/miner.hpp index 3a4697f1..08fa21ae 100644 --- a/src/include/miner.hpp +++ b/src/include/miner.hpp @@ -28,7 +28,7 @@ class Miner { void mine(); - void submit(const std::string &id, const std::string &path); + void submit(const std::string &path, std::string id); private: void checkRegularTasks(); diff --git a/src/main.cpp b/src/main.cpp index f370fc4b..b63dd764 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -125,11 +125,14 @@ int dispatch(Settings settings, const std::vector& args) { commands.mine(); } } else if (cmd == "submit") { - if (args.size() != 3) { + if (args.size() == 2) { + commands.submit(args.at(1), ""); + } else if (args.size() == 3) { + commands.submit(args.at(1), args.at(2)); + } else { std::cout << "invalid number of arguments" << std::endl; return 1; } - commands.submit(args.at(1), args.at(2)); } #ifdef _WIN64 // hidden helper command for updates on windows diff --git a/src/miner.cpp b/src/miner.cpp index 44d6d50b..494ba9e9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -205,11 +205,18 @@ void Miner::checkRegularTasks() { } } -void Miner::submit(const std::string &id, const std::string &path) { +void Miner::submit(const std::string &path, std::string id) { Parser parser; auto program = parser.parse(path); ConfigLoader::MAINTAINANCE_MODE = true; reload(); + if (id.empty() && program.ops.size() > 0 && !program.ops[0].comment.empty()) { + id = program.ops[0].comment; + auto n = id.find(':'); + if (n != std::string::npos) { + id = id.substr(0, n); + } + } OeisSequence seq(id); Settings settings(this->settings); settings.print_as_b_file = false;