Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/3/85; site ukma.UUCP Path: utzoo!watmath!clyde!cbosgd!ukma!sambo From: sambo@ukma.UUCP (Inventor of micro-S) Newsgroups: net.unix Subject: Re: comments in lex Message-ID: <1929@ukma.UUCP> Date: Fri, 28-Jun-85 19:52:26 EDT Article-I.D.: ukma.1929 Posted: Fri Jun 28 19:52:26 1985 Date-Received: Sun, 30-Jun-85 00:25:11 EDT References: <114@emacs.uucp> Reply-To: sambo@ukma.UUCP (Inventor of micro-S) Organization: Univ. of KY Mathematical Sciences Lines: 39 In article <114@emacs.uucp> ray@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@anl-mcs.arpa, or even anlams!ukma!sambo@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."