1 #include "BaseParser.hpp" 2 3 namespace pdal 4 { 5 namespace expr 6 { 7 checkEnd()8bool BaseParser::checkEnd() 9 { 10 // If we're at the end, we should have exhausted all tokens. 11 Token tok = m_lexer.get(); 12 if (tok != TokenType::Eof) 13 { 14 m_error = "Found '" + tok.sval() + "' after valid expression."; 15 return false; 16 } 17 return true; 18 } 19 peekToken()20Token BaseParser::peekToken() 21 { 22 Token t = m_lexer.get(); 23 m_lexer.put(t); 24 return t; 25 } 26 curToken() const27Token BaseParser::curToken() const 28 { 29 return m_curTok; 30 } 31 match(TokenType type)32bool BaseParser::match(TokenType type) 33 { 34 Token t = m_lexer.get(); 35 if (t.type() == type) 36 { 37 m_curTok = t; 38 return true; 39 } 40 m_lexer.put(t); 41 return false; 42 } 43 setError(const std::string & err)44void BaseParser::setError(const std::string& err) 45 { 46 if (m_error.empty()) 47 m_error = err; 48 } 49 clearError()50void BaseParser::clearError() 51 { 52 m_error.clear(); 53 } 54 55 } // namespace expr 56 } // namespace pdal 57