summaryrefslogtreecommitdiffstats
path: root/dimension/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'dimension/parse.c')
-rw-r--r--dimension/parse.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/dimension/parse.c b/dimension/parse.c
index c868d95..55ad78e 100644
--- a/dimension/parse.c
+++ b/dimension/parse.c
@@ -205,10 +205,11 @@ dmnsn_parse(const dmnsn_array *tokens)
setlocale(LC_CTYPE, "C");
setlocale(LC_NUMERIC, "C");
- for (i = 0; i < dmnsn_array_size(tokens); ++i) {
+ while (i < dmnsn_array_size(tokens)) {
dmnsn_array_get(tokens, i, &token);
- if (token.type == DMNSN_T_BOX) {
+ switch (token.type) {
+ case DMNSN_T_BOX:
if (dmnsn_parse_box(tokens, &i, astree) != 0) {
dmnsn_diagnostic(token.filename, token.line, token.col,
"Invalid box",
@@ -216,10 +217,11 @@ dmnsn_parse(const dmnsn_array *tokens)
dmnsn_token_name(token.type));
goto bailout;
}
- } else {
+ break;
+
+ default:
dmnsn_diagnostic(token.filename, token.line, token.col,
- "Expected '%s', found '%s'",
- dmnsn_token_name(DMNSN_T_BOX),
+ "Unexpected token '%s'",
dmnsn_token_name(token.type));
goto bailout;
}