Skip to main content

rl_lang/docs/entries/stdlib/rl/
lex.rs

1use crate::docs::entry::FnEntry;
2
3pub static LEX: FnEntry = FnEntry {
4    signature: "lex(code)",
5    description: "tokenizes a string of rl source code and returns each token as a (kind, lexeme, line) tuple, without parsing or running it",
6    example: "get std::rl::lex\n\nlex(\"dec int x = 1\") // [(\"Dec\", \"dec\", 1), (\"Int\", \"int\", 1), (\"Identifier\", \"x\", 1), (\"Equal\", \"=\", 1), (\"Integer\", \"1\", 1)]",
7    expected_output: None,
8    returns: "Result[arr[(string, string, int)]]",
9    errors: Some("returns an error if the source has invalid tokens (e.g. an unterminated string)"),
10    see_also: &["check", "eval"],
11    since: None,
12};