String module

match_token

procedure · 1 overloadSource

Reads the next token as parse_token does and returns it with whether it is equal to match. The token is removed from line whether or not it matches.

match_token :: (
    line: *string,
    match: string,
    delimiters := DEFAULT_DELIMITERS,
    spaces := DEFAULT_SPACES
) -> (value: string, success: bool)

Parameters

line: *string
match: string
delimiters := DEFAULT_DELIMITERS
spaces := DEFAULT_SPACES

Returns

value: string
success: bool
ExampleOpen in playground ↗
line := "if (x)";
_, matched := match_token(*line, "if");
assert(matched && line == " (x)");

See also