From d0a8e1dc080df9ed80083515eacae07cc5208107 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Fri, 26 Sep 2025 07:59:49 -0700 Subject: [PATCH] Fix: Use CommonJS for Nearley grammar preprocessor --- grammar.ne | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammar.ne b/grammar.ne index 40cbbc3..5e5bd55 100644 --- a/grammar.ne +++ b/grammar.ne @@ -1,7 +1,7 @@ @{% -import moo from 'moo'; +const moo = require('moo'); -export const lexer = moo.compile({ +const lexer = moo.compile({ ws: /[ \t]+/, nl: { match: /\n/, lineBreaks: true }, comment: /\/\/.*?$/, @@ -106,7 +106,7 @@ Identifier -> %identifier {% d => ({ type: 'Identifier', name: d[0].value }) %} Literal -> %number {% d => ({ type: 'NumericLiteral', value: Number(d[0].value) }) %} | %string {% d => ({ type: 'StringLiteral', value: d[0].value }) %} -Block -> %lbrace _ (KeyValuePairs):? _ %rbrace {% +Block -> %lbrace _ (KeyValuePairs):? _ %rparen {% (d) => ({ type: 'Block', properties: d[2] || [] }) %}