Sujet : Re: Command Languages Versus Programming Languages
De : rweikusat (at) *nospam* talktalk.net (Rainer Weikusat)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 21. Nov 2024, 18:01:48
Autres entêtes
Message-ID : <87v7wgr05f.fsf@doppelsaurus.mobileactivedefense.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
merlyn@stonehenge.com (Randal L. Schwartz) writes:
"Rainer" == Rainer Weikusat <rweikusat@talktalk.net> writes:
Rainer> ¹ I used to use a JSON parser written in OO-Perl which made
Rainer> extensive use of regexes for that. I've recently replaced that
Rainer> with a C/XS version which - while slightly larger (617 vs 410
Rainer> lines of text) - is over a hundred times faster and conceptually
Rainer> simpler at the same time.
>
I wonder if that was my famous "JSON parser in a single regex" from
https://www.perlmonks.org/?node_id=995856, or from one of the two CPAN
modules that incorporated it.
No. One of my use-cases is an interactive shell running in a web browser
using ActionCable messages to relay data between the browser and the
shell process on the computer supposed to be accessed in this way. For
this, I absolutely do need \u escapes. I also need this to be fast. Eg,
one of the nice properties of JSON is that the type of a value can be
determined by looking at the first character of it. This cries for an
implementation based on an array of pointers to 'value parsing routines'
of size 256 and determining the parser routine to use by using the first
character as index into this table (which will either yield a pointer to
the correct parser routine or NULL for a syntax error).