prebirth,birth,rebirth: Permit newlines in strings

This modifies each of the three lexers just to avoid confusion, even
though prebirth has no need for it.  Birth does have a need, however, since
rebirth will contain newlines---despite the relevant rebirth code (next
commit) not being expanded, it still has to go through the lexer, which
otherwise errors out.

* build-aux/bootstrap/birth.scm (lex): Permit newlines in string regex.
* build-aux/bootstrap/prebirth.js (lex): Permit newlines in string regex.
* build-aux/bootstrap/rebirth.scm (lex): Permit newlines in string regex.
master
Mike Gerwitz 2017-12-05 00:47:26 -05:00
parent 639948da02
commit 7f7a9704e5
Signed by: mikegerwitz
GPG Key ID: 8C917B7F5DC51BA2
3 changed files with 7 additions and 5 deletions

View File

@ -112,8 +112,9 @@
;; strings are delimited by opening and closing ASCII ;; strings are delimited by opening and closing ASCII
;; double quotes, which can be escaped with a ;; double quotes, which can be escaped with a
;; backslash ;; backslash
(("\"") (let ((str (js:match-regexp "^\"(|.*?[^\\\\])\"" (("\"") (let ((str (js:match-regexp
trim))) "^\"(|(?:.|\\\n)*?[^\\\\])\""
trim)))
(or str (parse-error (or str (parse-error
src pos src pos
"missing closing string delimiter")) "missing closing string delimiter"))

View File

@ -228,7 +228,7 @@ class Parser
// strings are delimited by opening and closing ASCII double quotes, // strings are delimited by opening and closing ASCII double quotes,
// which can be escaped with a backslash // which can be escaped with a backslash
else if ( trim[ 0 ] === '"' ) { else if ( trim[ 0 ] === '"' ) {
const str = trim.match( /^"(|.*?[^\\])"/ ); const str = trim.match( /^"(|(?:.|\n)*?[^\\])"/ );
if ( !str ) { if ( !str ) {
this._error( src, pos, "missing closing string delimiter" ); this._error( src, pos, "missing closing string delimiter" );
} }

View File

@ -112,8 +112,9 @@
;; strings are delimited by opening and closing ASCII ;; strings are delimited by opening and closing ASCII
;; double quotes, which can be escaped with a ;; double quotes, which can be escaped with a
;; backslash ;; backslash
(("\"") (let ((str (js:match-regexp "^\"(|.*?[^\\\\])\"" (("\"") (let ((str (js:match-regexp
trim))) "^\"(|(?:.|\\\n)*?[^\\\\])\""
trim)))
(or str (parse-error (or str (parse-error
src pos src pos
"missing closing string delimiter")) "missing closing string delimiter"))