From d693c9a164d3f1b887c4ed24487e1ebcfa0837d0 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Sat, 30 May 2026 11:56:38 -0700 Subject: [PATCH] Improve DSC expression grammar speed --- grammars/tree-sitter-dscexpression/grammar.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/grammars/tree-sitter-dscexpression/grammar.js b/grammars/tree-sitter-dscexpression/grammar.js index 4287b19b8..94c648745 100644 --- a/grammars/tree-sitter-dscexpression/grammar.js +++ b/grammars/tree-sitter-dscexpression/grammar.js @@ -11,16 +11,18 @@ export default grammar({ extras: $ => ['\n', ' '], + inline: $ => [$._booleanLiteral, $._argument, $._quotedString, $._expressionString], + rules: { statement: $ => choice( $.escapedStringLiteral, $._expressionString, $.stringLiteral, ), - escapedStringLiteral: $ => token(prec(PREC.ESCAPEDSTRING, seq('[[', /.*?/))), + escapedStringLiteral: $ => token(prec(PREC.ESCAPEDSTRING, seq('[[', /.*/))), _expressionString: $ => prec(PREC.EXPRESSIONSTRING, seq('[', $.expression, ']')), expression: $ => seq(field('function', $.function), optional(field('accessor',$.accessor))), - stringLiteral: $ => token(prec(PREC.STRINGLITERAL, /[^\[](.|\n)*?/)), + stringLiteral: $ => token(prec(PREC.STRINGLITERAL, /[^\[][\s\S]*/)), function: $ => prec(PREC.FUNCTION, seq(field('name', $.functionName), '(', field('args', optional($.arguments)), ')')), functionName: $ => choice( @@ -32,7 +34,7 @@ export default grammar({ _quotedString: $ => seq('\'', $.string, '\''), // ARM strings are not allowed to contain single-quote characters unless escaped - string: $ => /([^']|''|\n)*/, + string: $ => /([^']|'')*/, number: $ => /-?\d+/, boolean: $ => prec(PREC.BOOLEAN, $._booleanLiteral), _booleanLiteral: $ => choice('true', 'false'),