pub fn operands_and_operators<'a, T: ParserTrait>(
    parser: &'a T,
    path: &'a Path
) -> Option<Ops>
Expand description

Retrieves all the operators and operands of a code.

If None, it was not possible to retrieve the operators and operands of a code.

Examples

use std::path::PathBuf;

use rust_code_analysis::{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);

// Returns the operands and operators of each space in a code.
operands_and_operators(&parser, &path).unwrap();