From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mickey Petersen Newsgroups: gmane.emacs.bugs Subject: bug#61043: 30.0.50; `json-ts-mode': invalid font lock rule Date: Wed, 25 Jan 2023 07:27:46 +0000 Organization: Mastering Emacs Message-ID: <87h6wfvzqw.fsf@masteringemacs.org> References: <87lelrwv7f.fsf@masteringemacs.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1340"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e @VERSION@; emacs 30.0.50 Cc: "61043@debbugs.gnu.org" <61043@debbugs.gnu.org> To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 25 08:30:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKaEf-0000AK-Ev for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Jan 2023 08:30:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKaEP-0002Ko-5v; Wed, 25 Jan 2023 02:30:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKaEM-0002Ka-OO for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2023 02:30:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKaEM-0000Qx-EZ for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2023 02:30:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pKaEM-0007Mj-9H for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2023 02:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mickey Petersen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Jan 2023 07:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61043 X-GNU-PR-Package: emacs Original-Received: via spool by 61043-submit@debbugs.gnu.org id=B61043.167463177928257 (code B ref 61043); Wed, 25 Jan 2023 07:30:02 +0000 Original-Received: (at 61043) by debbugs.gnu.org; 25 Jan 2023 07:29:39 +0000 Original-Received: from localhost ([127.0.0.1]:58136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKaDy-0007Lh-Qm for submit@debbugs.gnu.org; Wed, 25 Jan 2023 02:29:39 -0500 Original-Received: from mail-am0eur02on2099.outbound.protection.outlook.com ([40.107.247.99]:43713 helo=EUR02-AM0-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKaDw-0007LT-Dr for 61043@debbugs.gnu.org; Wed, 25 Jan 2023 02:29:37 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+bmGNdflVCoK/cRVuxSkCEy9X2kIuAyv1YEOsmYigdtXSSWs5nWu+Kgofm2KjnBG5AGdJl06JksWQO2GQ2bHROw14UTG9f4kZ0w9eJeyEhTvgmzdhZxe+y21kslHAIHYN2mrQYCE/RnT36KaHu1YV8TehViq6EAsO3wmDxVy5UPSJfBrwn6ZJWTobtvvOIzc7YvV6NQHQgHaubhaGcUL4j5T451U15IYvGGtrNhMNtQ3dVuMniUTAicMb/ZzHuR/6uBai6gN47kqpL6IqVrDj7O8KibkJKLr3DbItM/GyuTpEpFhWwCm/mFxQJMdPAEMwi3El8mrBUa1Hxfn3R06g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Rddf8pA5XbXypIl/n6m7ZHoFT6E2U84M8WVn/Zscbx8=; b=cwpMKYcW+wxULgIxoDpdTSn9IcudpjEWA/p5jV5kQ0fawPRcrXfXgzvrWYFf5InVnZJRlYuV/VhmpekdTin4NN9htOgznIa+GVGjk0Q+SmQVrTwFBvvNK+Oz8CX7XpGR7zEALrI1+4QwuHJOXm1R79CLscZ2DipM9veURPtQ0iduiOIek5cfk0dLntyHJfI/Im+mUmStbumfnvMd25SHI29yhOOgFVS9ovQ/fYaqSoLIxFbeMKYcEDNiS+b72zmyJoC+3bkWQEsgKHPzNiBry4eb2Ppvd/HdOuYr3ERt8tut1lhid6w2nkmlFgQ6/870Lu2rMvGa2LLXCvWNDDDPcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 178.79.136.144) smtp.rcpttodomain=debbugs.gnu.org smtp.mailfrom=masteringemacs.org; dmarc=pass (p=none sp=none pct=100) action=none header.from=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semantical.onmicrosoft.com; s=selector1-semantical-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rddf8pA5XbXypIl/n6m7ZHoFT6E2U84M8WVn/Zscbx8=; b=Oeh5DYDXPr3oYcgG+/spoVEvIEwKz1FV+k0DiJzKwjjBImjBu2hB2f8MTkSFcFEpovNMsH36lG+SCOgO8b24oAVqXqm8GUfIO0Vi0aVxmZhExwqObKEosJsArPzX6vWw/xspHKuRUgHoq5SLXqpbxqNQpGJ3skiGQmI3hoWUl4E= Original-Received: from LO4P123CA0137.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:193::16) by LO2P265MB5469.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:25c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21; Wed, 25 Jan 2023 07:29:16 +0000 Original-Received: from CWLGBR01FT009.eop-gbr01.prod.protection.outlook.com (2603:10a6:600:193:cafe::e) by LO4P123CA0137.outlook.office365.com (2603:10a6:600:193::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.34 via Frontend Transport; Wed, 25 Jan 2023 07:29:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 178.79.136.144) smtp.mailfrom=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org;dmarc=pass action=none header.from=masteringemacs.org; Received-SPF: Pass (protection.outlook.com: domain of masteringemacs.org designates 178.79.136.144 as permitted sender) receiver=protection.outlook.com; client-ip=178.79.136.144; helo=semantical.co.uk; pr=C Original-Received: from semantical.co.uk (178.79.136.144) by CWLGBR01FT009.mail.protection.outlook.com (10.152.40.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.17 via Frontend Transport; Wed, 25 Jan 2023 07:29:15 +0000 Original-Received: by semantical.co.uk (Postfix, from userid 5001) id A36F5114002; Wed, 25 Jan 2023 07:29:13 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=masteringemacs.org; s=masteringemacs.org; t=1674631753; bh=yvjMslYg1VX4UquhIdQmWe8eibAaoYYoGZrkOmVVES0=; h=References:From:To:Cc:Subject:Date:In-reply-to:From; b=c8+gMRAY2gODlg2mrar7/Ax12nwKYl0Fq1uve34zTVxZ6a6L7e3A1gG9AonyYTBTX 1yMSIveGhVsCnV/JIzr45MoxdeGok3uSUQlH1xahtY7q2Q16l/n6QVRkh/sIVr7PH4 5RgaJ5pnWgO1fPXL4ei5CfpGwlFM/R13dT//cLXo= In-reply-to: X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLGBR01FT009:EE_|LO2P265MB5469:EE_ X-MS-Office365-Filtering-Correlation-Id: 8443d9d6-fcbb-47d7-a6f3-08dafea5dd32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nkBMqnsPWLCZBmMCBW0XaveBmmsYXdJCOqZ0bfUJWfL6DWiIs3mrcNypwuitiV+72E+XqvuQa9xNXEoE/v6uMnWL6qD5mQaqGuo6eFweFqaaPWO3Lp9TZ60UX0pSol03ef60EvfhR5wneB9aqFFM7tZPIotLd39dbzHiuTruKEIc6LmR4JX323lbySiPLGpLy1TqR/DBzpMj9vLZtwa5Sdado2YD9t2ebDAdyEyI6BdS6GYS8vML46ZSg4WrlOVZjKF5VPI8cY1qLmtPijUmVYUHSlc0vUVZKbI1svsekClnCxzv41a+MMjF6B7W1Me/1mxcddRwJgRgR7WLM200SUDm79bx3KL0d9+hBLVe0fHjUtsNtZpzELr8B5+STGn3ZLLTQo4XTp7HTbdtrnaQlW11zX2x8T9HGIIP+coSVWz4mJ4u6hyCCCNeevknEmJ/SH0l3fPQWMLYairVIBbt9IfWbUaewQWxZMoV2fWrMHd+jd3JOvEWqq44rpjf4GdVWUz2hSMHkIzW4wwg4vdZjgTOfDd562lFslhSEaMwpeSqZB26yJxm3y8KOeIgreQqkSyjwgv0FOTthId3C/Am2kiHMREQ8cMdfJwS6+QYqDaU8LFkN9Ojxh0IHcFxKe3UEAacAkWX+dVQ610BiqG6q+GyUBsdcAT2bG1bSO+A/YBxy5IBA6Asz0qW0Ne0rBbNv6r/YKLk/z9XLMsSpDgBhp4creaHcGnfXU98fjNAdLENiodNPrfMQrdS00Zp+ Eq7wYxWJdEE6homKvGvgz4vYQ== X-Forefront-Antispam-Report: CIP:178.79.136.144; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:semantical.co.uk; PTR:semantical.co.uk; CAT:NONE; SFS:(13230025)(136003)(39830400003)(346002)(376002)(396003)(451199018)(36840700001)(46966006)(47076005)(82310400005)(86362001)(36756003)(40480700001)(356005)(36860700001)(316002)(7636003)(7596003)(42186006)(2906002)(66899018)(41300700001)(4326008)(70206006)(70586007)(6862004)(8676002)(8936002)(5660300002)(478600001)(6266002)(26005)(186003)(83380400001)(336012)(2616005)(36916002)(6666004)(38230200001)(81973001)(14776008)(79816003); DIR:OUT; SFP:1102; X-OriginatorOrg: masteringemacs.org X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2023 07:29:15.7864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8443d9d6-fcbb-47d7-a6f3-08dafea5dd32 X-MS-Exchange-CrossTenant-Id: a4e27e3d-bab0-45e8-8942-e64cf9fbd34f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a4e27e3d-bab0-45e8-8942-e64cf9fbd34f; Ip=[178.79.136.144]; Helo=[semantical.co.uk] X-MS-Exchange-CrossTenant-AuthSource: CWLGBR01FT009.eop-gbr01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO2P265MB5469 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254102 Archived-At: Drew Adams writes: >> 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. > Agreed. Sadly, the JSON grammar in TS does not support comments, and so no comment support is possible. OTOH, because it is strict, it'll catch errors like trailing commas, etc. For 'lax' JSON, the best option is Javascript. > 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.