[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
10.2.3 Java Location Values
When the directive %locations
is used, the Java parser
supports location tracking, see Locations Overview.
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 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 position_type "class-name"
. This class must
be supplied by the user.
- Instance Variable of Location: Position begin
- Instance Variable of Location: Position end
The first, inclusive, position of the range, and the first beyond.
- Constructor on Location: Location (Position loc)
Create a
Location
denoting an empty range located at a given point.
- Constructor on Location: Location (Position begin, Position end)
Create a
Location
from the endpoints of the range.
- Method on Location: String toString ()
Prints the range represented by the location. For this to work properly, the position class should override the
equals
andtoString
methods appropriately.