Reads the next token and looks it up by name among the values of the enum type T. The second result is
false when no value has that name, and then the value is zero. The name is case sensitive.
parse_enum :: (
line: *string,
$T: Type,
delimiters := DEFAULT_DELIMITERS,
spaces := DEFAULT_SPACES
) -> (value: T, success: bool)
Parameters
- line: *string
- $T: Type
- delimiters := DEFAULT_DELIMITERS
- spaces := DEFAULT_SPACES
Returns
- value: T
- success: bool
Color :: enum { RED; GREEN; }
line := "GREEN;";
value, ok := parse_enum(*line, Color);
assert(ok && value == .GREEN && line == ";");