diff options
| -rw-r--r-- | pez.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -2438,6 +2438,12 @@ flushconst(Comp *cm) } static bool +reserved(const char *s) +{ + return !strcmp(s, "FOR") || !strcmp(s, "RET"); +} + +static bool primaryexpr(Comp *cm) { char buf[NAMEMAX]; @@ -2492,6 +2498,10 @@ primaryexpr(Comp *cm) // identifier *buf = c; TRY(readident(cm, buf + 1, sizeof buf - 1)); + if (reserved(buf)) { + comperr(cm, *buf, "'%s' is a reserved keyword", buf); + return 0; + } Ident: local = findlocal(cm, buf); if (local) { @@ -3325,6 +3335,10 @@ decl(Comp *cm, Local **pl, bool nofold) return 0; } TRY(readident(cm, name, sizeof name)); + if (reserved(name)) { + comperr(cm, *name, "'%s' is a reserved keyword", name); + return 0; + } eatspaces(cm); switch ((c = nextchr(cm))) { case ':': // constant |