Next: Java Parser Interface, Previous: Java Semantic Values, Up: Java Parsers [Contents][Index]
When the directive %locations
is used, the Java parser supports
location tracking, see Tracking Locations. An auxiliary user-defined
class defines a position, a single point in a file; Bison itself
defines a class representing a location, a range composed of a pair of
positions (possibly spanning several files). The location class is an inner
class of the parser; the name is Location
by default, and may also be
renamed using %define api.location.type {class-name}
.
The location class treats the position as a completely opaque value.
By default, the class name is Position
, but this can be changed
with %define api.position.type {class-name}
. This class must
be supplied by the user.
The first, inclusive, position of the range, and the first beyond.
Position
loc) ¶Create a Location
denoting an empty range located at a given point.
Position
begin, Position
end) ¶Create a Location
from the endpoints of the range.
Prints the range represented by the location. For this to work
properly, the position class should override the equals
and
toString
methods appropriately.