From 6a736a8fcd475448cb0c93d2b9cef2f6d1094dfd Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 29 Aug 2017 01:27:54 -0400 Subject: [PATCH] prebirth: Ignore comments in JS parser * build-aux/bootstrap/prebirth.js (parseLisp): Ingore comment tokens. (_lex): Recognize comments. --- build-aux/bootstrap/prebirth.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build-aux/bootstrap/prebirth.js b/build-aux/bootstrap/prebirth.js index 21bf389..c16de94 100644 --- a/build-aux/bootstrap/prebirth.js +++ b/build-aux/bootstrap/prebirth.js @@ -97,6 +97,10 @@ class Parser // a very simple bootstrap lisp) switch ( type ) { + // ignore comments + case 'comment': + return result; + // closing parenthesis (end of sexp) case 'close': if ( depth === 0 ) { @@ -197,6 +201,12 @@ class Parser return []; } + // comment until end of line + if ( trim[ 0 ] === ';' ) { + const eol = trim.match( /^(.*?)(\n|$)/ ); + return this._token( 'comment', eol[ 1 ], trim, pos ); + } + // left and right parenthesis are handled in the same manner: they // produce distinct tokens with single-character lexemes if ( trim[ 0 ] === '(' ) {