/********************************************************************** * * set_pos * * Sets nullable, firstpos and lastpos in whole tree. */ static bool set_pos(void) { REG1 int i; REG2 node_t* tnode = rbuf.tree; for (i = 0; i <= rbuf.root; i++, tnode++) { nullable(tnode); if ((tnode->firstpos = calloc(rbuf.setsize, 1)) == NULL) return FALSE; firstpos(i, tnode); if ((tnode->lastpos = calloc(rbuf.setsize, 1)) == NULL) return FALSE; lastpos(i, tnode); } return TRUE; }
/*! * \brief output method */ std::ostream & InputError::output(std::ostream & os) const { os << filename; if (line > 0) { os << ":" << line; } os << ": error"; if (!token.empty()) switch (type) { case exception::InputError::SYNTAX_ERROR: os << " near '" << token << "'"; break; case exception::InputError::SEMANTIC_ERROR: os << ": '" << token << "'"; break; default: /* do nothing */ ; } os << ": " << message; ifstream ifs(filename.c_str()); if (ifs.good()) { string line_, arrows; for (int i = 0; i < line; ++i) { getline(ifs, line_); } size_t firstpos(line_.find(token)); for (unsigned int i = 0; i < firstpos; ++i) { arrows += " "; } for (unsigned int i = 0; i < token.size(); ++i) { arrows += "^"; } os << endl << endl << line_ << endl << arrows << endl << endl; } ifs.close(); return os; }