Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/sourcepos/sourcepos.h File Reference

Classes for sophisticated source position (file/line/lpos, include hierarchy) handling. More...

#include <lib/sconfig.h>
#include <lib/tl/refnode.h>
#include <lib/sourcepos/sourcefile.h>

Include dependency graph for sourcepos.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

class  _InternalSourcePosition
 Internally used source position class. More...


Defines

#define _LIB_SOURCEPOS_SOURCEPOS_H_   1

Typedefs

typedef RefNode< _InternalSourcePositionSourcePosition
 This is the source position "class" to be used by other code.


Functions

bool operator== (const SourcePosition &a, const SourcePosition &b)
 operator==() returns true for same position in same file.

bool operator!= (const SourcePosition &a, const SourcePosition &b)
 operator!=() returns false for same position in same file.


Detailed Description

Classes for sophisticated source position (file/line/lpos, include hierarchy) handling.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [

For each toplevel input (source) file you read in with your parser, create a SourcePositionArchive. Use the SourcePositionArchive to get SourceFileNodes and SourcePosition indicators. When parsing is done, you may safely delete the SourcePositionArchive since the SourceFileNodes and SourcePositions which are still in use will not get deleted (they clean up themselves when no longer in use).

Note that SourcePositionArchive is not C++ - safe, create it once and only use pointers to it.

SourcePosition represents a source position (line and possibly lpos in a file); it is meant for mass usage and kept as small as possible: SourcePosition contains only one pointer, so it is 4 or 8 bytes (depending on the architecture and padding).
The pointer points to InternalSourcePosition.
SourcePosition does reference counting and is "C++-safe" (assignment and copy construction implemnented).

Note that InternalSourcePosition are normally shared among all tokens with the same position - thus you can save a lot of memory when not using lpos (always set it to -1 when creating the position information in your scanner/lexer).

(Internal) SourcePosition points to a SourceFileNode which represents a source file. SourceFileNodes are organized in a tree structure representing the include hierarchy. Note that if you include the same file twice, two SourceFileNodes will get allocated. SourceFileNode is C++ - safe (copy constructor and assignment).

The SourceFileNodes can also save the include statement position and size -- information which may be needed in case you want to concatenate all the included files into a single one. (Internally uses InternalSourceFileNode and reference counting.)

For more docu, check the comments around the public functions/methods in this file.

Definition in file sourcepos.h.


Define Documentation

#define _LIB_SOURCEPOS_SOURCEPOS_H_   1
 

Definition at line 19 of file sourcepos.h.


Typedef Documentation

typedef RefNode<_InternalSourcePosition> SourcePosition
 

This is the source position "class" to be used by other code.

Definition at line 75 of file sourcepos.h.

Referenced by _InternalSourcePosition::CreateSinglePosition(), SourcePositionCache::find(), SourcePositionArchive::GetPos(), main(), SCLocation::operator=(), _InternalSourcePosition::PosRangeString(), _InternalSourcePosition::PosStringRelative(), SCLocation::SCLocation(), and SourcePositionCache::store().


Function Documentation

bool operator!= const SourcePosition a,
const SourcePosition b
[inline]
 

operator!=() returns false for same position in same file.

See also:
SourceFileNode::operator==()

Definition at line 185 of file sourcepos.h.

References operator==().

bool operator== const SourcePosition a,
const SourcePosition b
[inline]
 

operator==() returns true for same position in same file.

See also:
SourceFileNode::operator==()

Definition at line 178 of file sourcepos.h.


Generated on Sat Feb 19 22:34:36 2005 for Ray by doxygen 1.3.5