Function qasm::lex [] [src]

pub fn lex(input: &str) -> Vec<Token>

Take a source string with no includes or comments and returns the tokens

The source string can be processed with the process function. The tokens are all varients of Token. An illegal token will be returned for any unrechognised tokens.

Examples

extern crate qasm;

let source = r#"
OPENQASM 2.0;
qreg a[3];
CX a[0], a[1];
"#;

let tokens = qasm::lex(source);
println!("{:?}", tokens);
// [OpenQASM, Real(2.0), Semicolon,
//  QReg, Id("a"), LSParen, NNInteger(3), RSParen, Semicolon,
//  Id("CX"), Id("a"), LSParen, NNInteger(0), RSParen, Comma, Id("a"), LSParen, NNInteger(1), RSParen, Semicolon]