Sujet : Re: Command Languages Versus Programming Languages
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.miscDate : 25. Nov 2024, 05:08:24
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <8634jgrm4n.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Kaz Kylheku <
643-408-1753@kylheku.com> writes:
Here is an example: using a regex match to capture a C comment /* ... */
in Lex compared to just recognizing the start sequence /* and handling
the discarding of the comment in the action.
>
Without non-greedy repetition matching, the regex for a C comment is
quite obtuse. The procedural handling is straightforward: read
characters until you see a * immediately followed by a /.
Regular expressions are neither greedy nor non-greedy. One of the
key points of regular expressions is that they are declarative
rather than procedural. Any procedural change of behavior overlaid
on a regular expression is a property of the tool, not the regular
expression. It's easy to write a regular expression that exactly
matches a /* ... */ comment and that isn't hard to understand.