Skip to content

Commit

Permalink
ptx: improve parser
Browse files Browse the repository at this point in the history
  • Loading branch information
romnn committed Apr 7, 2024
1 parent 68ce7cf commit 60b7d66
Show file tree
Hide file tree
Showing 8 changed files with 2,546 additions and 446 deletions.
1 change: 0 additions & 1 deletion ptx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ bytes = "1"
[dev-dependencies]
once_cell = "1"
snailquote = "0"
# pest-test = "0"
diff = { path = "../diff" }
7 changes: 7 additions & 0 deletions ptx/bison/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "ptxbison"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
24 changes: 24 additions & 0 deletions ptx/bison/src/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
fn test() {
let args = [
"-y",
"-d",
"./src/ref/intersim2/config.y",
"--file-prefix=./src/ref/intersim2/config.parser",
"-Wno-yacc",
];
let bison_cmd = duct::cmd("bison", &args).unchecked();
let result = bison_cmd.run()?;
println!("{}", String::from_utf8_lossy(&result.stdout));
eprintln!("{}", String::from_utf8_lossy(&result.stderr));

if !result.status.success() {
eyre::bail!(
"command {:?} exited with code {:?}",
[&["bison"], args.as_slice()].concat(),
result.status.code()
);
}
}

fn main() {
}
14 changes: 14 additions & 0 deletions ptx/bison/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
491 changes: 491 additions & 0 deletions ptx/bison/src/ptx.l

Large diffs are not rendered by default.

Loading

0 comments on commit 60b7d66

Please sign in to comment.