Function rust_code_analysis::dump_ops [−][src]
Expand description
Dumps all operands and operators of a code.
Returns a Result
value, when an error occurs.
Examples
use std::path::PathBuf;
use rust_code_analysis::{dump_ops, operands_and_operators, CppParser, ParserTrait};
let source_code = "int a = 42;";
// The path to a dummy file used to contain the source code
let path = PathBuf::from("foo.c");
let source_as_vec = source_code.as_bytes().to_vec();
// The parser of the code, in this case a CPP parser
let parser = CppParser::new(source_as_vec, &path, None);
// Retrieve all operands and operators
let ops = operands_and_operators(&parser, &path).unwrap();
// Dump all operands and operators
dump_ops(&ops).unwrap();