From 1e4e30342b7a3b3a24886a632fbac53035d98871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Dujava?= <19737748+jdujava@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:17:26 +0200 Subject: [PATCH] Support various \def-like and \let-like commands (#167) Signed-off-by: Jonas Dujava --- grammar.js | 7 +++++-- src/grammar.json | 34 ++++++++++++++++++++++++++++++---- src/node-types.json | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/grammar.js b/grammar.js index 47ae79004..303d312ee 100644 --- a/grammar.js +++ b/grammar.js @@ -989,11 +989,14 @@ module.exports = grammar({ ), old_command_definition: $ => - seq(field('command', '\\def'), field('declaration', $.command_name)), + seq( + field('command', choice('\\def', '\\gdef', '\\edef', '\\xdef')), + field('declaration', $.command_name) + ), let_command_definition: $ => seq( - field('command', '\\let'), + field('command', choice('\\let', '\\glet')), field('declaration', $.command_name), optional('='), field('implementation', $.command_name), diff --git a/src/grammar.json b/src/grammar.json index e36d37131..a2ebfe26d 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -5593,8 +5593,25 @@ "type": "FIELD", "name": "command", "content": { - "type": "STRING", - "value": "\\def" + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "\\def" + }, + { + "type": "STRING", + "value": "\\gdef" + }, + { + "type": "STRING", + "value": "\\edef" + }, + { + "type": "STRING", + "value": "\\xdef" + } + ] } }, { @@ -5614,8 +5631,17 @@ "type": "FIELD", "name": "command", "content": { - "type": "STRING", - "value": "\\let" + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "\\let" + }, + { + "type": "STRING", + "value": "\\glet" + } + ] } }, { diff --git a/src/node-types.json b/src/node-types.json index 3fe42ef4a..31c057156 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -4572,6 +4572,10 @@ "multiple": false, "required": true, "types": [ + { + "type": "\\glet", + "named": false + }, { "type": "\\let", "named": false @@ -5501,6 +5505,18 @@ { "type": "\\def", "named": false + }, + { + "type": "\\edef", + "named": false + }, + { + "type": "\\gdef", + "named": false + }, + { + "type": "\\xdef", + "named": false } ] }, @@ -9167,6 +9183,10 @@ "type": "\\documentclass", "named": false }, + { + "type": "\\edef", + "named": false + }, { "type": "\\end", "named": false @@ -9207,6 +9227,14 @@ "type": "\\fvolcite", "named": false }, + { + "type": "\\gdef", + "named": false + }, + { + "type": "\\glet", + "named": false + }, { "type": "\\gls", "named": false @@ -9631,6 +9659,10 @@ "type": "\\vref", "named": false }, + { + "type": "\\xdef", + "named": false + }, { "type": "]", "named": false