From: Drew Adams <drew.adams@oracle.com>
To: Mickey Petersen <mickey@masteringemacs.org>,
"61043@debbugs.gnu.org" <61043@debbugs.gnu.org>
Subject: bug#61043: 30.0.50; `json-ts-mode': invalid font lock rule
Date: Tue, 24 Jan 2023 21:08:09 +0000 [thread overview]
Message-ID: <SJ0PR10MB5488FAC65D2B42472922C45BF3C99@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87lelrwv7f.fsf@masteringemacs.org>
> There's a comment font lock rule in `json-ts-mode'. However, that is
> illegal and againt the JSON spec, and indeed the search query fails
> because `comment' is not a valid node type.
Caveat: Not following this thread, ignorant of
tree sitter, and probably ignorant of the use-
case context.
JSON syntax per its spec(s) is one thing.
JSON out there in the wild is something else.
There are zillions of JSON documents that
aren't well-formed per the specs. And lots of
apps that create and use such data.
As a result, in the real world, tools that we
expect to be useful for working with real data
need to be _able_ (optionally) to handle at
least the more common such deviations from
what the specs prescribe.
One way to do that is to have a variable/mode
that controls the kind(s) of well-formedness
you want to enforce. E.g., have two modes:
lax and strict. Or let functions dealing with
data have an optional arg that specifies the
syntax (lax or strict) to enforce.
And of course, we'd want to document just what
"lax" mode means: what syntax departures from
the specs our lax syntax tolerates.
A lax syntax, for example, often reflects the
JavaScript syntax for object fields; boolean
and null values aren't case-sensitive; and
it's more permissive with respect to numerals,
whitespace, and escaping of Unicode characters
than what the JSON specs require.
E.g., in JavaScript notation, a field name in
an object literal can be, but need not be, in
double quotation marks. And alternatively it
can be in single quotation marks.
Other things often allowed:
* An extra comma (,) after the last element of
an array or the last member of an object
(e.g., [a, b, c,], {a:b, c:d,}).
* Numerals with leading zeros (e.g., 0042.3).
* Fractional numerals that lack 0 before the
decimal point (e.g., .14 instead of 0.14).
* Numerals with no fractional part after the
decimal point (e.g., 342. or 1.e27).
* A plus sign (+) preceding a numeral, meaning
that the number is non-negative (e.g., +1.3).
* Treating all ASCII control chars, and the
ASCII space character, as (insignificant)
whitespace chars.
Lax-syntax JSON data is everywhere. It's good
to have tools that enforce the strict syntax of
the standards, but it's also good to have tools
that tolerate real-world, loosey-goosey JSON.
HTH.
next prev parent reply other threads:[~2023-01-24 21:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-24 20:09 bug#61043: 30.0.50; `json-ts-mode': invalid font lock rule Mickey Petersen
2023-01-24 21:08 ` Drew Adams [this message]
2023-01-24 21:10 ` Drew Adams
2023-01-25 7:27 ` Mickey Petersen
2023-01-25 1:28 ` Dmitry Gutov
2023-01-25 7:29 ` Mickey Petersen
2023-01-25 12:08 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-25 12:09 ` Mickey Petersen
2023-01-25 13:14 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-25 13:30 ` Dmitry Gutov
2023-01-25 13:00 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SJ0PR10MB5488FAC65D2B42472922C45BF3C99@SJ0PR10MB5488.namprd10.prod.outlook.com \
--to=drew.adams@oracle.com \
--cc=61043@debbugs.gnu.org \
--cc=mickey@masteringemacs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).