Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Programming exercise/challenge Date: Tue, 29 Dec 2020 20:05:38 -0800 Organization: A noiseless patient Spider Lines: 30 Message-ID: <86im8kueel.fsf@linuxsc.com> References: <86wnxwkyol.fsf@linuxsc.com> <20201208160437.44860a2351f9f468bd03f65f@gmail.com> <86im9b5sxg.fsf@linuxsc.com> <20201212233442.8debf749db7ca9bee3ec7bcd@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="bad9f3398650fdf0e991b5310f5ac4d7"; logging-data="15117"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18o47vw3rLfWKOzTtQi2If29Ay65q66E+w=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:Y+hyDlAsGqm23bR3vyzXNtZhwrs= sha1:nHAQuiz+yxjWtKdS1ikzPzJLXeE= Xref: csiph.com comp.lang.c:157881 kegs@provalid.com (Kent Dickey) writes: > In article <20201212233442.8debf749db7ca9bee3ec7bcd@gmail.com>, > Anton Shepelev wrote: > >> My latest version refelcts my idea of a conceptually compact >> solution with as little repetition as possible. Comment- >> stripping is implemented as two connected state machines. >> The outer machine takes care of line continuations while the >> inner one processes the joined lines of code. >> >> Since the inner machine I needed was a Mealy machine with >> only one state whose output depended on the transition, I >> converted it into a Moore machine using a hack that let me >> avoid additional states. In order not to introduce >> additional state properties, I store them implicit in the >> very ordering of the states. The table-driven approach saves >> the repetition of the same input and test request in the >> handlers of individual states. > > I haven't looked this over yet, but it fails two of my tests: > > Test '/* mixing */ "quotes /* so there */ '/* hmm */ " /* last one */ > Line 36 "/* mixing */ 'quotes /* so there */ "/* hmm */ ' /* last one */ Note that this input is not lexically well-formed. The first line has a string starting with " that is not finished by the end of that line. Also the second line has a character constant starting with ' that is not finished by the end of that line. (tested with gcc -E -)