Skip to content

Commit

Permalink
Parser (#455)
Browse files Browse the repository at this point in the history
Closes #466.
Closes #465.
Closes #447.
Closes #443.
Closes #346.
Closes #219. 
Closes #539.
Closes #522.
  • Loading branch information
aannleax authored Oct 1, 2024
2 parents 4edd5b1 + ef216ae commit 3bdecc9
Show file tree
Hide file tree
Showing 294 changed files with 23,350 additions and 13,453 deletions.
1,232 changes: 921 additions & 311 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
[workspace]
resolver = "2"
default-members = [
"nemo",
"nemo-cli",
"nemo-physical",
"nemo-python",
]
members = [
"nemo",
"nemo-cli",
"nemo-physical",
"nemo-python",
"nemo-language-server",
"nemo-wasm",
]

Expand Down
2 changes: 2 additions & 0 deletions nemo-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ clap = { version = "4.0.32", features = [ "derive", "cargo", "env" ] }
colored = "2"
env_logger = "*"
serde_json = "1.0.108"
thiserror = "1.0"

nemo = { path = "../nemo" }
ariadne = "0.4.1"

[dev-dependencies]
assert_cmd = "2.0"
Expand Down
10 changes: 5 additions & 5 deletions nemo-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ pub(crate) struct OutputArgs {

impl OutputArgs {
/// Creates an output file manager with the current options
pub(crate) fn export_manager(self) -> Result<ExportManager, Error> {
let export_manager = ExportManager::new()
.set_base_path(self.export_directory)
pub(crate) fn export_manager(&self) -> Result<ExportManager, Error> {
let export_manager = ExportManager::default()
.set_base_path(self.export_directory.clone())
.overwrite(self.overwrite)
.compress(self.gz);
Ok(export_manager)
Expand All @@ -120,11 +120,11 @@ pub(crate) struct TracingArgs {
/// Facts for which a derivation trace should be computed;
/// multiple facts can be separated by a semicolon, e.g. "P(a, b);Q(c)".
#[arg(long = "trace", value_delimiter = ';', group = "trace-input")]
pub(crate) facts_to_be_traced: Option<Vec<String>>,
pub(crate) facts: Option<Vec<String>>,
/// Specify one or multiple input files for the facts that should be traced.
/// The file format is the same as for the "trace" CLI argument.
#[arg(long = "trace-input-file", value_parser, group = "trace-input")]
pub(crate) trace_input_file: Option<Vec<PathBuf>>,
pub(crate) input_file: Option<Vec<PathBuf>>,
/// File to export the trace to
#[arg(long = "trace-output", requires = "trace-input")]
pub(crate) output_file: Option<PathBuf>,
Expand Down
46 changes: 46 additions & 0 deletions nemo-cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//! This module defines all the errors that can occur while executing nemo-cli.

use thiserror::Error;

/// Error that occur during execution of Nemo's CLI app
#[derive(Error, Debug)]
pub enum CliError {
/// Error if no input rule files are specified
#[error("no input file was given")]
NoInput,
/// Error if the user asked for an unimplemented feature
#[error("multiple rule files are currently unsupported")]
MultipleFilesNotImplemented,
/// Error while serializing data to a file
#[error("Error while serializing data to {filename}.")]
SerializationError {
/// Name of the file where data could not have been serialized into
filename: String,
},
/// Errors on reading a file
#[error("failed to read `{filename}`: {error}")]
IoReading {
/// Contains the wrapped error
error: std::io::Error,
/// Filename which caused the error
filename: String,
},
/// Error while parsing fact for tracing
#[error("unable to parse fact: {fact}")]
TracingInvalidFact {
/// Incorrectly formatted fact
fact: String,
},
/// Error while parsing a rule file
#[error("unable to parse program `{filename}`")]
ProgramParsing {
/// Filename of the rule file
filename: String,
},
/// Error resulting from io operations
#[error(transparent)]
IoError(#[from] std::io::Error),
/// Error originating from nemo
#[error(transparent)]
NemoError(#[from] nemo::error::Error),
}
Loading

0 comments on commit 3bdecc9

Please sign in to comment.