Fix: Use CommonJS for Nearley grammar preprocessor

This commit is contained in:
2025-09-26 07:59:49 -07:00
parent b187f9e42b
commit d0a8e1dc08

View File

@@ -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] || [] })
%}