third trial: get the token i(vss) as a whole in the lexer,

this prevents the parser from generating the spurious vector vss.
No need to do an extra translation i(vss) -> vss#branch.
This commit is contained in:
Holger Vogt 2020-03-08 19:59:09 +01:00
parent fbd17bc25a
commit 11cf6e709b
1 changed files with 9 additions and 3 deletions

View File

@ -709,10 +709,8 @@ int PPlex(YYSTYPE *lvalp, struct PPltype *llocp, char **line)
*
* what is valid here ?
* foo dc1.foo dc1.@m1[vth]
* this too ?
* vthing#branch
* should we convert the pseudo identifier ?
* i(v5) --> v5#branch
* i(vthing)
*/
for (; *sbuf && !strchr(specials, *sbuf); sbuf++)
if (*sbuf == '@') {
@ -727,6 +725,14 @@ int PPlex(YYSTYPE *lvalp, struct PPltype *llocp, char **line)
}
break;
}
/* keep the identifier i(vss) as a single token, even as dc1.i(vss) */
else if (prefix("i(v", sbuf)) {
if (get_r_paren(&sbuf) == 1) {
fprintf(stderr, "Error: missing ')' in token\n %s\n", start);
break;
}
sbuf--;
}
lvalp->str = copy_substring(start, sbuf);
lexer_return(TOK_STR, 0);