comments in lex
Inventor of micro-S
sambo at ukma.UUCP
Sat Jun 29 09:52:26 AEST 1985
In article <114 at emacs.uucp> ray at emacs.uucp (Ray Reeves) writes:
>This is what I did:
>
>startcom \/\*
>endcom \*\/
>%%
>{startcom}[^{endcom}]{endcom} printf("%s","comment")
Here is what I do. If there is a better way, let me know.
%%
"/*"[^*\n]* {
int c, i;
if ((c = input ()) == '*')
if ((c = input ()) == '/') {
/* Have found a comment. */
} /* if ((c = input ()) == '/') */
else {
unput (c); unput ('*'); unput ('/');
/* This makes lex think that the very next thing on
the input is also a comment. */
} /* else - if ((c = input ()) == '/') */
else {
/* found '\n' */
unput ('*'); unput ('/');
/* Processing may be different upon reaching the end of
line - in my compiler I keep track of which line of
text I am looking at. Also, by doing things this way
I am hoping to avoid overflowing the input buffer. */
} /* else - first if ((c */
}
-----------------------------------------
Samuel A. Figueroa, Dept. of CS, Univ. of KY, Lexington, KY 40506-0027
ARPA: ukma!sambo<@ANL-MCS>, or sambo%ukma.uucp at anl-mcs.arpa,
or even anlams!ukma!sambo at ucbvax.arpa
UUCP: {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!sambo,
or cbosgd!ukma!sambo
"Micro-S is great, if only people would start using it."
More information about the Comp.unix
mailing list