You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Line terminators are almost always just a simple white space. The lexer needs to take them into account to allow automatic semicolon insertion and allow checking for places where line terminators are not allowed.
So, in this scenario, I would propose for the parser cursor to automatically skip line terminators when calling next(), peek() or expect(). We already have a expect_semicolon() function that will take into account line terminators. We would also need a peek_semicolon() that would check if a semicolon could be inserted (or is present), to check for things such as continue; or continue expr;.
Finally, we would need another expect_no_lineterminator() function, that would make sure that there is no line terminator at the given position. I think this would make it easier to implement the spec, or at least our parsing code would be closer to what we see in the spec.
This would also allow removing the skip() function, the {peek/next}_skip_lineterminator() functions, and review the next_if() functions, since there seems to be a lot of duplicated functionality here.
The text was updated successfully, but these errors were encountered:
Line terminators are almost always just a simple white space. The lexer needs to take them into account to allow automatic semicolon insertion and allow checking for places where line terminators are not allowed.
So, in this scenario, I would propose for the parser cursor to automatically skip line terminators when calling
next()
,peek()
orexpect()
. We already have aexpect_semicolon()
function that will take into account line terminators. We would also need apeek_semicolon()
that would check if a semicolon could be inserted (or is present), to check for things such ascontinue;
orcontinue expr;
.Finally, we would need another
expect_no_lineterminator()
function, that would make sure that there is no line terminator at the given position. I think this would make it easier to implement the spec, or at least our parsing code would be closer to what we see in the spec.This would also allow removing the
skip()
function, the{peek/next}_skip_lineterminator()
functions, and review thenext_if()
functions, since there seems to be a lot of duplicated functionality here.The text was updated successfully, but these errors were encountered: