constantParser function
Implementation
Parser<Expression> constantParser(List<Constant> constants) {
return ChoiceParser(
constants.map(
(constant) => string(constant.name) & (letter() | digit()).not(),
),
)
.flatten('constant expected')
.trim()
.map(
(name) => Value(
constants.firstWhere((constant) => constant.name == name).value,
),
);
}