Skip to main content

stix_pattern/
lib.rs

1//! Lexer and parser for the STIX 2.1 patterning language.
2//!
3//! # Example
4//!
5//! ```
6//! use stix_pattern::parse;
7//!
8//! let pattern = parse("[file:hashes.'SHA-256' = 'abc']").unwrap();
9//! let json = serde_json::to_string(&pattern).unwrap();
10//! assert!(json.contains("SHA-256"));
11//! ```
12//!
13//! Patterns can also be lowered to a three-address [`ir::Program`] and rendered
14//! back to canonical pattern text:
15//!
16//! ```
17//! use stix_pattern::{ir, parse};
18//!
19//! let pattern = parse("[file:size>1024]").unwrap();
20//! let program = ir::lower(&pattern);
21//! assert_eq!(ir::render(&program), "[file:size > 1024]");
22//! ```
23
24#![warn(missing_docs)]
25
26pub mod ast;
27pub mod error;
28pub mod ir;
29pub mod lexer;
30pub mod parser;
31
32pub use ast::*;
33pub use error::{ParseError, Span};
34pub use parser::{parse, MAX_NESTING};