From 5108b326247ad21ca5baf13f8f49a2ebdcec4abe Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Sun, 20 Nov 2022 00:19:41 +0200 Subject: [PATCH] Added line breaks in parser strings Actual line breaks and \n both work --- app/imports/parser/grammar.js | 6 +++--- app/imports/parser/grammar.ne | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/imports/parser/grammar.js b/app/imports/parser/grammar.js index ec217527..43f5b70f 100644 --- a/app/imports/parser/grammar.js +++ b/app/imports/parser/grammar.js @@ -1,4 +1,4 @@ -// Generated automatically by nearley, version 2.16.0 +// Generated automatically by nearley, version 2.20.1 // http://github.com/Hardmath123/nearley function id(x) { return x[0]; } @@ -9,8 +9,8 @@ function id(x) { return x[0]; } const lexer = moo.compile({ number: /[0-9]+(?:\.[0-9]+)?/, string: { - match: /'.*?'|".*?"/, - value: s => s.slice(1, -1), + match: /'[^']*'|"[^"]*"/, + value: s => s.slice(1, -1).replace('\\n', '\n'), }, name: { match: /[a-zA-Z_#$]*[a-ce-zA-Z_#$][a-zA-Z0-9_#$]*/, diff --git a/app/imports/parser/grammar.ne b/app/imports/parser/grammar.ne index 51d1ece2..3ebdba75 100644 --- a/app/imports/parser/grammar.ne +++ b/app/imports/parser/grammar.ne @@ -7,8 +7,8 @@ const lexer = moo.compile({ number: /[0-9]+(?:\.[0-9]+)?/, string: { - match: /'.*?'|".*?"/, - value: s => s.slice(1, -1), + match: /'[^']*'|"[^"]*"/, + value: s => s.slice(1, -1).replace('\\n', '\n'), }, name: { match: /[a-zA-Z_#$]*[a-ce-zA-Z_#$][a-zA-Z0-9_#$]*/,