js-on-sx: ASI — :nl token flag + return restricted production (525/526 unit, 148/148 slice)
Lexer: adds :nl (newline-before) boolean to every token. scan! resets the flag before each skip-ws! call; skip-ws! sets it true when it consumes \n or \r. Parser: jp-token-nl? reads the flag; jp-parse-return-stmt stops before the expression when a newline precedes it (return\n42 → return undefined). Four new tests cover the restricted production and the raw flag. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -835,6 +835,12 @@
|
||||
jp-eat-semi
|
||||
(fn (st) (if (jp-at? st "punct" ";") (do (jp-advance! st) nil) nil)))
|
||||
|
||||
(define
|
||||
jp-token-nl?
|
||||
(fn
|
||||
(st)
|
||||
(let ((tok (jp-peek st))) (if tok (= (get tok :nl) true) false))))
|
||||
|
||||
(define
|
||||
jp-parse-vardecl
|
||||
(fn
|
||||
@@ -1166,6 +1172,7 @@
|
||||
(or
|
||||
(jp-at? st "punct" ";")
|
||||
(jp-at? st "punct" "}")
|
||||
(jp-token-nl? st)
|
||||
(jp-at? st "eof" nil))
|
||||
(do (jp-eat-semi st) (list (quote js-return) nil))
|
||||
(let
|
||||
|
||||
Reference in New Issue
Block a user