Commits

Eric Roshan Eisner committed 2854e71 Draft

give more helpful error than "Unexpected string"

Comments (0)

Files changed (1)

 				v := Value{num, Unitless}
 				// Peek at the next token to see if it's a unit.
 				if i+1 < len(tokens) {
-					u, ok := parseUnit(tokens[i+1])
-					if ok {
+					if u, ok := parseUnit(tokens[i+1]); ok {
 						i += 1
 						v = v.Mul(u)
 					}
 				}
 				consumer.eatValue(v)
+			} else if _, ok := parseUnit(token); ok {
+				return nil, parseError("Did not find number before unit " + token)
 			} else {
-				// this is an unrecognized unit or string blob out of place
-				return nil, parseError("Unexpected string `" + token + "` in input.")
+				return nil, parseError("`" + token + "` was not recognized as a number or unit.")
 			}
 		}
 	}