1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/* $Id$
*
* Copyright (C) 2007-2009 FAUmachine Team <info@faumachine.org>.
* This program is free software. You can redistribute it and/or modify it
* under the terms of the GNU General Public License, either version 2 of
* the License, or (at your option) any later version. See COPYING.
*/
#ifndef __LOCATION_HPP_INCLUDED
#define __LOCATION_HPP_INCLUDED
#include <ostream>
#include <string>
namespace ast {
/** location of a definiton. */
class Location {
public:
//! c'tor
/** @param lineNo line number in the file.
* @param filenm name of the file.
*/
Location(
unsigned int lineNo,
const std::string *filenm
) : line(lineNo),
filename(filenm),
information(NULL) {}
//! alternate c'tor for builtins.
/** @param info additional information.
*/
Location(const char *info) : line(0),
filename(NULL),
information(info) {}
//! dummy d'tor
virtual ~Location() {}
/** Output the location to a stream.
* @param out stream to which the location should get written to.
* @return stream on which the location was written to.
*/
std::ostream& put(std::ostream &out) const;
/** line in the file */
unsigned int line;
/** filename */
const std::string *filename;
/** other information */
const char *information;
};
/** overloaded operator to conveniently output locations.
* @param stream stream to which a location should get written to.
* @param loc location reference that should get written to the stream.
* @return modified stream
*/
std::ostream&
operator <<(std::ostream& stream, const Location& loc);
}; /* namespace ast */
#endif /* __LOCATION_HPP_INCLUDED */
|