Function qasm::process [] [src]

pub fn process(input: &str, cwd: &Path) -> String

Remove comments from an input string and resolves include statements.

This function has 2 arguments, the input string, and the path that the file is in. The path is used to resolve the include statements.

This function returns a String that has no comments and no include statements. The include statements will have been replaced by the text of the include file.

This function will panic when the included file doesn't exist or when it couldn't be read.

Example

extern crate qasm;
use std::env;

let source = r#"
OPENQASM 2.0;
// Here is a comment
include "sample.inc";

qreg a[3];
// And so on
"#;

let cwd = env::current_dir().unwrap();
qasm::process(source, &cwd);
/* Will Return:
 *
 * ```
 * OPENQASM 2.0;
 *
 * (CONTENTS OF SAMPLE.INC)
 *
 * qreg a[3];
 * ```
 */