.SH PREPROCESSOR
The preprocessor is a text based way of modifying the input before
-the assembly step.
+the assembly step. Stray tokens after a directive are ignored!
Preprocessor directives start with a # and have to be the first non-space character in a line.
All lines that are not a preprocessor directive, or are not part of a preprocessor block (macro, or if)
return 0;
}
-int ulas_preprochasstray(struct ulas_preproc *pp, const char *pline, size_t n) {
-
- // the end of a directive should have no further tokens!
- if (ulas_tok(&pp->tok, &pline, n) != 0) {
- ULASERR("Stray tokens '%s' at end of preprocessor directive\n",
- pp->tok.buf);
- return 1;
- }
-
- return 0;
-}
-
void ulas_trimend(char c, char *buf, size_t n) {
size_t buflen = strnlen(buf, n);
// remove trailing new line if present
}
char *name = strdup(pp->tok.buf);
- if (ulas_preprochasstray(pp, pline, n)) {
- free(name);
- return -1;
- }
-
struct ulas_str val = ulas_str(32);
memset(val.buf, 0, 32);
struct ulas_ppdef *def =
ulas_preprocgetdef(pp, pp->tok.buf, pp->tok.maxlen);
- // the end of a directive should have no further tokens!
- if (ulas_preprochasstray(pp, pline, n)) {
- ULASERR("Stray token at end of preprocessor directive!");
- return -1;
- }
-
char buf[ULAS_LINEMAX];
memset(buf, 0, ULAS_LINEMAX);
break;
}
- // the end of a directive should have no further tokens!
- if (ulas_preprochasstray(pp, pline, n)) {
- ULASERR("Stray token at end of preprocessor directive!");
- return -1;
- }
dirdone:
return found_dir;
} else if (dst) {