示例#1
0
void QsCodeParser::parseHeaderFile(const Location& location,
                                   const QString& filePath,
                                   Tree *tree)
{
    qsTre = tree;

    FILE *in = fopen(QFile::encodeName(filePath), "r");
    if (in == 0) {
	location.error(tr("Cannot open Qt Script class list '%1'")
			.arg(filePath));
	return;
    }

    Location fileLocation(filePath);
    Tokenizer fileTokenizer(fileLocation, in);
    int tok = fileTokenizer.getToken();
    while (tok != Tok_Eoi) {
	if (tok == Tok_Ident) {
	    ClassNode *quickClass = new ClassNode(qsTre->root(),
						   fileTokenizer.lexeme());
	    quickClass->setLocation(fileTokenizer.location());
	}
        else {
	    fileTokenizer.location().error(tr("Unexpected token '%1' in Qt"
					       " Script class list")
					    .arg(fileTokenizer.lexeme()));
	    break;
	}
	tok = fileTokenizer.getToken();
    }
    fclose(in);
}
示例#2
0
/*!
  Parses the source file identified by \a filePath and adds its
  parsed contents to the database. The \a location is used for
  reporting errors.
 */
void PureDocParser::parseSourceFile(const Location& location, const QString& filePath)
{
    QFile in(filePath);
    currentFile_ = filePath;
    if (!in.open(QIODevice::ReadOnly)) {
        location.error(tr("Can't open source file '%1' (%2)").arg(filePath).arg(strerror(errno)));
        currentFile_.clear();
        return;
    }

    reset();
    Location fileLocation(filePath);
    Tokenizer fileTokenizer(fileLocation, in);
    tokenizer = &fileTokenizer;
    readToken();

    /*
      The set of open namespaces is cleared before parsing
      each source file. The word "source" here means cpp file.
     */
    qdb_->clearOpenNamespaces();

    processQdocComments();
    in.close();
    currentFile_.clear();
}