Next: , Previous: , Up: Java Parsers   [Contents][Index]


10.3.3 Java Location Values

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.

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 and toString methods appropriately.