Back to problems

Evaluate variables in simple arithmetic DSL

Algorithm · Applied Intuition · Hard

Implement an evaluator for a small configuration language. The input program is a string containing zero or more blank lines and one assignment per non-empty line: An matches [a-zA-Z_][a-zA-Z0-9_]*. An expression is a sequence of integer literals and identifier references joined only by the binary operators + and -. There are no parentheses, and all operations are evaluated strictly left to right. Whitespace may appear between any tokens and has no semantic meaning; adjacent…

Checking your access…