Expand description
Parsing the Souper IR text format.
This module provides both high- and low-level parsing utilities:
-
The high-level parsing functions are
parse_*_file
andparse_*_string
which can be used to parse full replacements, LHSes, or RHSes either from files on disk or from an in-memory string. -
The low-level parsing utilities are the
Parse
trait and theParser
struct. These can be used to parse a single instance of an LHS or RHS, for example.
§Example
use souper_ir::parse::parse_replacements_str;
use std::path::Path;
let replacements = parse_replacements_str("
;; First replacement.
%x:i32 = var
%2lx = slt 2, %x
pc %2lx 1
%1lx = slt 1, %x
cand %1lx 1
;; Second replacement.
%bb = block 3
%phi1 = phi %bb, 1:i32, 2, 3
%phi2 = phi %bb, 2:i32, 4, 6
%phi1x2 = mul %phi1, 2
cand %phi2 %phi1x2
", Some(Path::new("example.souper")))?;
assert_eq!(replacements.len(), 2);
Structs§
- An error that occurs during parsing.
- A Souper text parser buffer.
Traits§
- A trait for AST nodes that can be parsed from text.
- A trait for whether an AST node looks like it comes next.
Functions§
- Parse a sequence of
LeftHandSide
s from a file on disk. - Parse a sequence of
LeftHandSide
s from an in-memory string. - Parse a sequence of
Replacement
s from a file on disk. - Parse a sequence of
Replacement
s from an in-memory string. - Parse a sequence of
RightHandSide
s from a file on disk. - Parse a sequence of
RightHandSide
s from an in-memory string.
Type Aliases§
- A
Result
type for parsing.