fix: function body comments.

This commit is contained in:
Artem Kobzar
2022-04-07 20:08:21 +02:00
committed by teamcity
parent 672561b847
commit 86df391cab
4 changed files with 18 additions and 6 deletions
@@ -153,7 +153,7 @@ public class Parser {
Node pn = nf.createBlock(ts.tokenPosition);
try {
int tt;
while ((tt = ts.peekToken()) > TokenStream.EOF && tt != TokenStream.RC) {
while ((tt = ts.peekTokenWithComment()) > TokenStream.EOF && tt != TokenStream.RC) {
if (tt == TokenStream.FUNCTION) {
ts.getToken();
pn.addChildToBack(function(ts, false));
@@ -536,13 +536,19 @@ public class TokenStream {
}
public int peekToken() throws IOException {
int result = getToken();
return peekTokenHelper(getToken());
}
this.pushbackToken = result;
public int peekTokenWithComment() throws IOException {
return peekTokenHelper(getTokenWithComment());
}
private int peekTokenHelper(int token) throws IOException {
this.pushbackToken = token;
lastPosition = secondToLastPosition;
lastTokenPosition = tokenPosition;
tokenno--;
return result;
return token;
}
public int peekTokenSameLine() throws IOException {