treat // comments as comments to avoid confusion on [;${}'"]. Reference: /n/sources/patch/maybe/yacc-c++-comm Date: Sat Jul 23 11:17:12 CES 2011 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/yacc.c Sat Jul 23 11:17:07 2011 +++ /sys/src/cmd/yacc.c Sat Jul 23 11:17:03 2011 @@ -141,7 +141,7 @@ char* infile; /* input file name */ int numbval; /* value of an input number */ -char tokname[NAMESIZE+4]; /* input token name, slop for runes and 0 */ +char tokname[NAMESIZE+UTFmax+1]; /* input token name, slop for runes and 0 */ /* structure declarations */ @@ -1209,7 +1209,7 @@ parser = PARSERS; break; default: - error("illegal option: %c", ARGC()); + usage(); }ARGEND openup(stemc, dflag, vflag, ytab, ytabc); @@ -2056,25 +2056,38 @@ return; case '/': - /* look for comments */ - Bputrune(faction, c); - c = Bgetrune(finput); - if(c != '*') - goto swt; + /* look for comments; sync with skipcom() */ - /* it really is a comment */ Bputrune(faction, c); c = Bgetrune(finput); - while(c >= 0) { - while(c == '*') { + switch(c){ + default: + goto lcopy; + case '/': + Bputrune(faction, c); + while((c = Bgetrune(finput)) != Beof){ Bputrune(faction, c); - if((c=Bgetrune(finput)) == '/') - goto lcopy; + if(c == '\n'){ + lineno++; + goto loop; + } } + break; + + case '*': Bputrune(faction, c); - if(c == '\n') - lineno++; - c = Bgetrune(finput); + match = 0; + while((c = Bgetrune(finput)) != Beof){ + Bputrune(faction, c); + if(c == '\n') + lineno++; + if(match && c == '/') + goto loop; + match = c == '*'; + } + break; + case Beof: + break; } error("EOF inside comment");