/** * Consume a (possibly implicit) semi-colon. Reports an error if a semi-colon is not present. */ private void eatPossibleImplicitSemiColon() { if (peek(TokenType.SEMI_COLON) && peekToken().location.start.line == getLastLine()) { eat(TokenType.SEMI_COLON); return; } if (peekImplicitSemiColon()) { return; } reportError("Semi-colon expected"); }
/** * Consume a (possibly implicit) semi-colon. Reports an error if a semi-colon is not present. */ private void eatPossibleImplicitSemiColon() { if (peek(TokenType.SEMI_COLON) && peekToken().location.start.line == getLastLine()) { eat(TokenType.SEMI_COLON); return; } if (peekImplicitSemiColon()) { return; } reportError("Semi-colon expected"); }
private boolean peekImplicitSemiColon(int index) { boolean lineAdvanced; if (index == 0) { lineAdvanced = getNextLine() > getLastLine(); } else { lineAdvanced = peekToken(index).location.start.line > peekToken(index - 1).location.end.line; } return lineAdvanced || peek(index, TokenType.SEMI_COLON) || peek(index, TokenType.CLOSE_CURLY) || peek(index, TokenType.END_OF_FILE); }
private boolean peekImplicitSemiColon(int index) { boolean lineAdvanced; if (index == 0) { lineAdvanced = getNextLine() > getLastLine(); } else { lineAdvanced = peekToken(index).location.start.line > peekToken(index - 1).location.end.line; } return lineAdvanced || peek(index, TokenType.SEMI_COLON) || peek(index, TokenType.CLOSE_CURLY) || peek(index, TokenType.END_OF_FILE); }