Remove dependencies, add doc.rs metadata (#1450)
* Remove dependency, add doc.rs metadata * remove lazy_static * even less lazy_static * serial_test no default
This commit is contained in:
parent
c84c105fb9
commit
e89e8dbaab
@ -21,4 +21,4 @@ debug = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
libafl = { path = "../../libafl/" }
|
libafl = { path = "../../libafl/" }
|
||||||
libafl_bolts = { path = "../../libafl_bolts/" }
|
libafl_bolts = { path = "../../libafl_bolts/" }
|
||||||
postcard = "0.7"
|
postcard = { version = "1.0", features = ["alloc"], default-features = false } # no_std compatible serde serialization format
|
@ -11,6 +11,9 @@ keywords = ["fuzzing", "testing", "security"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "derive", "llmp_compression", "llmp_small_maps", "llmp_broker_timeouts", "rand_trait", "fork", "prelude", "gzip", "regex", "serdeany_autoreg", "tui_monitor"]
|
default = ["std", "derive", "llmp_compression", "llmp_small_maps", "llmp_broker_timeouts", "rand_trait", "fork", "prelude", "gzip", "regex", "serdeany_autoreg", "tui_monitor"]
|
||||||
std = ["serde_json", "serde_json/std", "nix", "serde/std", "bincode", "wait-timeout", "uuid", "backtrace", "serial_test", "libafl_bolts/std", "typed-builder"] # print, env, launcher ... support
|
std = ["serde_json", "serde_json/std", "nix", "serde/std", "bincode", "wait-timeout", "uuid", "backtrace", "serial_test", "libafl_bolts/std", "typed-builder"] # print, env, launcher ... support
|
||||||
@ -102,7 +105,7 @@ concat-idents = { version = "1.1.3", optional = true }
|
|||||||
libcasr = { version = "2.7", optional = true}
|
libcasr = { version = "2.7", optional = true}
|
||||||
|
|
||||||
# optional-dev deps (change when target.'cfg(accessible(::std))'.test-dependencies will be stable)
|
# optional-dev deps (change when target.'cfg(accessible(::std))'.test-dependencies will be stable)
|
||||||
serial_test = { version = "2", optional = true }
|
serial_test = { version = "2", optional = true, default-features = false, features = ["logging"] }
|
||||||
|
|
||||||
# AGPL
|
# AGPL
|
||||||
# !!! this create requires nightly
|
# !!! this create requires nightly
|
||||||
|
@ -30,6 +30,7 @@ pub trait HashSetState<T> {
|
|||||||
|
|
||||||
/// The state of [`NewHashFeedback`]
|
/// The state of [`NewHashFeedback`]
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug)]
|
#[derive(Default, Serialize, Deserialize, Clone, Debug)]
|
||||||
|
#[allow(clippy::unsafe_derive_deserialize)]
|
||||||
pub struct NewHashFeedbackMetadata {
|
pub struct NewHashFeedbackMetadata {
|
||||||
/// Contains information about untouched entries
|
/// Contains information about untouched entries
|
||||||
pub hash_set: HashSet<u64>,
|
pub hash_set: HashSet<u64>,
|
||||||
|
@ -6,6 +6,7 @@ use crate::observers::concolic::{serialization_format::MessageFileReader, SymExp
|
|||||||
|
|
||||||
/// A metadata holding a buffer of a concolic trace.
|
/// A metadata holding a buffer of a concolic trace.
|
||||||
#[derive(Default, Serialize, Deserialize, Debug)]
|
#[derive(Default, Serialize, Deserialize, Debug)]
|
||||||
|
#[allow(clippy::unsafe_derive_deserialize)]
|
||||||
pub struct ConcolicMetadata {
|
pub struct ConcolicMetadata {
|
||||||
/// Constraints data
|
/// Constraints data
|
||||||
buffer: Vec<u8>,
|
buffer: Vec<u8>,
|
||||||
|
@ -11,9 +11,12 @@ keywords = ["fuzzing", "testing", "security"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "derive", "llmp_compression", "llmp_small_maps", "rand_trait", "prelude", "gzip", "serdeany_autoreg", "alloc"]
|
default = ["std", "derive", "llmp_compression", "llmp_small_maps", "rand_trait", "prelude", "gzip", "serdeany_autoreg", "alloc"]
|
||||||
std = ["serde_json", "serde_json/std", "hostname", "nix", "serde/std", "uuid", "byteorder", "backtrace", "uds", "serial_test", "alloc"] # print, env, ... support
|
std = ["serde_json", "serde_json/std", "hostname", "nix", "serde/std", "uuid", "backtrace", "uds", "serial_test", "alloc"] # print, env, ... support
|
||||||
alloc = ["serde/alloc", "hashbrown", "postcard", "erased-serde/alloc", "ahash"] # Enables all features that allocate in no_std
|
alloc = ["serde/alloc", "hashbrown", "postcard", "erased-serde/alloc", "ahash"] # Enables all features that allocate in no_std
|
||||||
derive = ["libafl_derive"] # provide derive(SerdeAny) macro.
|
derive = ["libafl_derive"] # provide derive(SerdeAny) macro.
|
||||||
rand_trait = ["rand_core"] # If set, libafl's rand implementations will implement `rand::Rng`
|
rand_trait = ["rand_core"] # If set, libafl's rand implementations will implement `rand::Rng`
|
||||||
@ -62,18 +65,17 @@ hostname = { version = "^0.3", optional = true } # Is there really no gethostnam
|
|||||||
rand_core = { version = "0.6", optional = true }
|
rand_core = { version = "0.6", optional = true }
|
||||||
nix = { version = "0.26", optional = true }
|
nix = { version = "0.26", optional = true }
|
||||||
uuid = { version = "1.4", optional = true, features = ["serde", "v4"] }
|
uuid = { version = "1.4", optional = true, features = ["serde", "v4"] }
|
||||||
byteorder = { version = "1.4", optional = true }
|
|
||||||
clap = {version = "4.0", features = ["derive", "wrap_help"], optional = true} # CLI parsing, for libafl_bolts::cli / the `cli` feature
|
clap = {version = "4.0", features = ["derive", "wrap_help"], optional = true} # CLI parsing, for libafl_bolts::cli / the `cli` feature
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
|
|
||||||
pyo3 = { version = "0.18.3", optional = true, features = ["serde", "macros"] }
|
pyo3 = { version = "0.18.3", optional = true, features = ["serde", "macros"] }
|
||||||
|
|
||||||
# optional-dev deps (change when target.'cfg(accessible(::std))'.test-dependencies will be stable)
|
# optional-dev deps (change when target.'cfg(accessible(::std))'.test-dependencies will be stable)
|
||||||
serial_test = { version = "2", optional = true }
|
serial_test = { version = "2", optional = true, default-features = false, features = ["logging"] }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
libc = "0.2" # For (*nix) libc
|
libc = "0.2" # For (*nix) libc
|
||||||
uds = { version = "0.4", optional = true, default_features = false }
|
uds = { version = "0.4", optional = true, default-features = false }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
windows = { version = "0.51.1", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_System_Diagnostics_Debug", "Win32_System_Kernel", "Win32_System_Memory", "Win32_Security", "Win32_System_SystemInformation"] }
|
windows = { version = "0.51.1", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_System_Diagnostics_Debug", "Win32_System_Kernel", "Win32_System_Memory", "Win32_Security", "Win32_System_SystemInformation"] }
|
||||||
|
@ -87,9 +87,10 @@ fn calculate() -> Uuid {
|
|||||||
let mut hasher = from_type_id(hasher);
|
let mut hasher = from_type_id(hasher);
|
||||||
|
|
||||||
let mut bytes = [0; 16];
|
let mut bytes = [0; 16];
|
||||||
<byteorder::NativeEndian as byteorder::ByteOrder>::write_u64(&mut bytes[..8], hasher.finish());
|
bytes[..8].copy_from_slice(&hasher.finish().to_ne_bytes());
|
||||||
|
|
||||||
hasher.write_u8(0);
|
hasher.write_u8(0);
|
||||||
<byteorder::NativeEndian as byteorder::ByteOrder>::write_u64(&mut bytes[8..], hasher.finish());
|
bytes[8..].copy_from_slice(&hasher.finish().to_ne_bytes());
|
||||||
|
|
||||||
*uuid::Builder::from_bytes(bytes)
|
*uuid::Builder::from_bytes(bytes)
|
||||||
.set_variant(uuid::Variant::RFC4122)
|
.set_variant(uuid::Variant::RFC4122)
|
||||||
|
@ -13,6 +13,9 @@ categories = ["development-tools::testing", "emulators", "embedded", "os", "no-s
|
|||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["build", "clone"]
|
default = ["build", "clone"]
|
||||||
build = ["which", "cmake"] # common functionality to build symcc
|
build = ["which", "cmake"] # common functionality to build symcc
|
||||||
|
@ -14,6 +14,9 @@ categories = ["development-tools::testing", "emulators", "embedded", "os", "no-s
|
|||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# skips building and linking the C++ part of the runtime
|
# skips building and linking the C++ part of the runtime
|
||||||
no-cpp-runtime = []
|
no-cpp-runtime = []
|
||||||
@ -22,13 +25,12 @@ no-cpp-runtime = []
|
|||||||
unchecked_unwrap = "4"
|
unchecked_unwrap = "4"
|
||||||
ctor = "0.2"
|
ctor = "0.2"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
libafl = { path = "../../libafl", version = "0.10.1", default-features=false, features=["std"] }
|
libafl = { path = "../../libafl", version = "0.10.1", default-features=false, features=["std", "serdeany_autoreg"] }
|
||||||
libafl_bolts = { path = "../../libafl_bolts", version = "0.10.1", default-features=false, features=["std"] }
|
libafl_bolts = { path = "../../libafl_bolts", version = "0.10.1", default-features=false, features=["std", "serdeany_autoreg"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cmake = "0.1"
|
cmake = "0.1"
|
||||||
bindgen = "0.63"
|
bindgen = "0.63"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
lazy_static = "1.4"
|
|
||||||
which = "4.4"
|
which = "4.4"
|
||||||
symcc_libafl = { path = "../symcc_libafl", version = "0.10.1" }
|
symcc_libafl = { path = "../symcc_libafl", version = "0.10.1" }
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
cell::RefCell,
|
||||||
env,
|
env,
|
||||||
fs::File,
|
fs::File,
|
||||||
io::Write,
|
io::Write,
|
||||||
@ -6,18 +7,17 @@ use std::{
|
|||||||
process::exit,
|
process::exit,
|
||||||
};
|
};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use regex::{Regex, RegexBuilder};
|
use regex::{Regex, RegexBuilder};
|
||||||
use symcc_libafl::clone_symcc;
|
use symcc_libafl::clone_symcc;
|
||||||
|
|
||||||
const SYMCC_RUNTIME_FUNCTION_NAME_PREFIX: &str = "_cpp_";
|
const SYMCC_RUNTIME_FUNCTION_NAME_PREFIX: &str = "_cpp_";
|
||||||
|
|
||||||
lazy_static! {
|
thread_local! {
|
||||||
static ref FUNCTION_NAME_REGEX: Regex = Regex::new(r"pub fn (\w+)").unwrap();
|
static FUNCTION_NAME_REGEX: RefCell<Regex> = RefCell::new(Regex::new(r"pub fn (\w+)").unwrap());
|
||||||
static ref EXPORTED_FUNCTION_REGEX: Regex = RegexBuilder::new(r"(pub fn \w+\([^\)]*\)[^;]*);")
|
static EXPORTED_FUNCTION_REGEX: RefCell<Regex> = RefCell::new(RegexBuilder::new(r"(pub fn \w+\([^\)]*\)[^;]*);")
|
||||||
.multi_line(true)
|
.multi_line(true)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -88,7 +88,8 @@ fn write_cpp_function_export_macro(out_path: &Path, cpp_bindings: &bindgen::Bind
|
|||||||
() => {{",
|
() => {{",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
EXPORTED_FUNCTION_REGEX
|
EXPORTED_FUNCTION_REGEX.with(|x| {
|
||||||
|
x.borrow()
|
||||||
.captures_iter(&cpp_bindings.to_string())
|
.captures_iter(&cpp_bindings.to_string())
|
||||||
.for_each(|captures| {
|
.for_each(|captures| {
|
||||||
writeln!(
|
writeln!(
|
||||||
@ -98,6 +99,7 @@ fn write_cpp_function_export_macro(out_path: &Path, cpp_bindings: &bindgen::Bind
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
writeln!(
|
writeln!(
|
||||||
macro_file,
|
macro_file,
|
||||||
" }};
|
" }};
|
||||||
@ -156,17 +158,21 @@ fn write_rust_runtime_macro_file(out_path: &Path, symcc_src_path: &Path) {
|
|||||||
($macro:path; $($extra_ident:path),*) => {{",
|
($macro:path; $($extra_ident:path),*) => {{",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
EXPORTED_FUNCTION_REGEX
|
EXPORTED_FUNCTION_REGEX.with(|x| {
|
||||||
|
x.borrow()
|
||||||
.captures_iter(&rust_bindings.to_string())
|
.captures_iter(&rust_bindings.to_string())
|
||||||
.for_each(|captures| {
|
.for_each(|captures| {
|
||||||
writeln!(
|
writeln!(
|
||||||
rust_runtime_macro,
|
rust_runtime_macro,
|
||||||
" $macro!({},{}; $($extra_ident),*);",
|
" $macro!({},{}; $($extra_ident),*);",
|
||||||
&captures[1].replace("_rsym_", ""),
|
&captures[1].replace("_rsym_", ""),
|
||||||
&FUNCTION_NAME_REGEX.captures(&captures[1]).unwrap()[1]
|
&FUNCTION_NAME_REGEX
|
||||||
|
.with(|x| x.borrow().captures(&captures[1]))
|
||||||
|
.unwrap()[1]
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
writeln!(
|
writeln!(
|
||||||
rust_runtime_macro,
|
rust_runtime_macro,
|
||||||
" }};
|
" }};
|
||||||
@ -178,7 +184,7 @@ fn write_rust_runtime_macro_file(out_path: &Path, symcc_src_path: &Path) {
|
|||||||
fn write_symcc_runtime_bindings_file(out_path: &Path, cpp_bindings: &bindgen::Bindings) {
|
fn write_symcc_runtime_bindings_file(out_path: &Path, cpp_bindings: &bindgen::Bindings) {
|
||||||
let mut bindings_file = File::create(out_path.join("bindings.rs")).unwrap();
|
let mut bindings_file = File::create(out_path.join("bindings.rs")).unwrap();
|
||||||
cpp_bindings.to_string().lines().for_each(|l| {
|
cpp_bindings.to_string().lines().for_each(|l| {
|
||||||
if let Some(captures) = FUNCTION_NAME_REGEX.captures(l) {
|
if let Some(captures) = FUNCTION_NAME_REGEX.with(|x| x.borrow().captures(l)) {
|
||||||
let function_name = &captures[1];
|
let function_name = &captures[1];
|
||||||
writeln!(
|
writeln!(
|
||||||
bindings_file,
|
bindings_file,
|
||||||
@ -202,7 +208,7 @@ fn write_symcc_rename_header(rename_header_path: &Path, cpp_bindings: &bindgen::
|
|||||||
cpp_bindings
|
cpp_bindings
|
||||||
.to_string()
|
.to_string()
|
||||||
.lines()
|
.lines()
|
||||||
.filter_map(|l| FUNCTION_NAME_REGEX.captures(l))
|
.filter_map(|l| FUNCTION_NAME_REGEX.with(|x| x.borrow().captures(l)))
|
||||||
.map(|captures| captures[1].to_string())
|
.map(|captures| captures[1].to_string())
|
||||||
.for_each(|val| {
|
.for_each(|val| {
|
||||||
writeln!(
|
writeln!(
|
||||||
|
@ -17,6 +17,9 @@ categories = [
|
|||||||
"no-std"
|
"no-std"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["serdeany_autoreg"]
|
default = ["serdeany_autoreg"]
|
||||||
cmplog = []
|
cmplog = []
|
||||||
@ -71,4 +74,4 @@ paste = "1.0"
|
|||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serial_test = "1"
|
serial_test = { version = "2", default-features = false, features = ["logging"] }
|
||||||
|
@ -11,6 +11,9 @@ keywords = ["fuzzing", "qemu", "instrumentation"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["fork", "build_libqasan", "serdeany_autoreg"]
|
default = ["fork", "build_libqasan", "serdeany_autoreg"]
|
||||||
python = ["pyo3", "pyo3-build-config"]
|
python = ["pyo3", "pyo3-build-config"]
|
||||||
|
@ -17,6 +17,9 @@ categories = [
|
|||||||
"no-std",
|
"no-std",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
slirp = [] # build qemu with host libslirp (for user networking)
|
slirp = [] # build qemu with host libslirp (for user networking)
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@ keywords = ["fuzzing", "qemu", "instrumentation"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# The following architecture features are mutually exclusive.
|
# The following architecture features are mutually exclusive.
|
||||||
x86_64 = [] # build qemu for x86_64 (default)
|
x86_64 = [] # build qemu for x86_64 (default)
|
||||||
|
@ -12,6 +12,9 @@ edition = "2021"
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
python = ["pyo3", "libafl_qemu/python", "pyo3-build-config"]
|
python = ["pyo3", "libafl_qemu/python", "pyo3-build-config"]
|
||||||
default = []
|
default = []
|
||||||
|
@ -12,6 +12,9 @@ edition = "2021"
|
|||||||
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"]
|
||||||
|
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "sanitizers_flags"]
|
default = ["std", "sanitizers_flags"]
|
||||||
std = ["libafl/std"]
|
std = ["libafl/std"]
|
||||||
|
@ -15,10 +15,9 @@ categories = ["development-tools::testing", "emulators", "embedded", "os", "no-s
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
libafl = { path = "../../../libafl" }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
postcard = "1.0"
|
postcard = { version = "1.0", features = ["alloc"], default-features = false } # no_std compatible serde serialization format
|
||||||
lazy_static = "1.4.0"
|
|
||||||
libafl = { path = "../../../libafl" }
|
|
||||||
clap = { version = "4.0", features = ["derive"] }
|
clap = { version = "4.0", features = ["derive"] }
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
|
@ -4,14 +4,16 @@ use std::{
|
|||||||
io::{BufReader, Write},
|
io::{BufReader, Write},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
|
sync::OnceLock,
|
||||||
};
|
};
|
||||||
|
|
||||||
use clap::{self, Parser};
|
use clap::{self, Parser};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use libafl::generators::gramatron::{Automaton, Trigger};
|
use libafl::generators::gramatron::{Automaton, Trigger};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
static RE: OnceLock<Regex> = OnceLock::new();
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(
|
#[command(
|
||||||
name = "construct_automata",
|
name = "construct_automata",
|
||||||
@ -69,10 +71,8 @@ struct Stacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn tokenize(rule: &str) -> (String, Vec<String>, bool) {
|
fn tokenize(rule: &str) -> (String, Vec<String>, bool) {
|
||||||
lazy_static! {
|
let re = RE.get_or_init(|| Regex::new(r"([r])*'([\s\S]+)'([\s\S]*)").unwrap());
|
||||||
static ref RE: Regex = Regex::new(r"([r])*'([\s\S]+)'([\s\S]*)").unwrap();
|
let cap = re.captures(rule).unwrap();
|
||||||
}
|
|
||||||
let cap = RE.captures(rule).unwrap();
|
|
||||||
let is_regex = cap.get(1).is_some();
|
let is_regex = cap.get(1).is_some();
|
||||||
let terminal = cap.get(2).unwrap().as_str().to_owned();
|
let terminal = cap.get(2).unwrap().as_str().to_owned();
|
||||||
let ss = cap.get(3).map_or(vec![], |m| {
|
let ss = cap.get(3).map_or(vec![], |m| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user