pub fn parse(tokens: &[Token]) -> Result<Statement, String>
Expand description
Parses a sequence of tokens into a statement.
§Arguments
tokens
- A slice of tokens to be parsed.
§Returns
A Statement
representing the parsed tokens, or an error if the parsing fails.
§Errors
This function returns an error string if the token sequence is invalid.
§Examples
use r2rust_core::lexer::tokenize;
use r2rust_core::parser::parse;
let tokens = tokenize("x <- 10 + 32");
let statement = parse(&tokens).unwrap();