Exemple #1
0
void SemanticsVisitor::visit(Identifier& id) {
	id.setType(0); // init to error type. NOTICE by design, null attribute and error type is 0.
	try {
		Attributes* attributeRef = currentSymbolTable().retrieveSymbol(id.name());
		if (isDataObject(attributeRef)) {
			id.setAttributes(attributeRef);
		} else {
			errorLog() << id.name() << " does not name a data object.\n";
		}
	} catch (std::runtime_error& e) {
		errorLog() << id.name() << " has not been declared.\n";
	}
}
void addIdS( string * str, int type ) {
    string * cpdStr = new string( *str );
    Identifier * id = new Identifier();
    id->setKey( cpdStr );
    id->setType( type );
    if( !bst.add( id ) ) {
        delete( cpdStr );
        delete( id );
        string error = "Redeclaration of ";
        error.append( *str );
        yyerror( error.c_str() );
    }
}