public abstract static class BaseParser.WithPositions<Token> extends BaseParser<Token>
getStartPos()
/ getEndPos()
getStartPos(int)
/ getEndPos(int)
getStartPos(String)
/ getEndPos(String)
The following methods are also inherited from this class but should only be used by the generated code and not in semantic actions:
BaseParser.ParsingException, BaseParser.WithPositions<Token>
_jl_lastTokenEnd, _jl_lastTokenStart, _jl_lexbuf, _jl_nextToken
Modifier | Constructor and Description |
---|---|
protected |
WithPositions(String version,
T lexbuf,
Function<T,Token> tokens) |
Modifier and Type | Method and Description |
---|---|
protected void |
enter(int ruleSize)
Enters a new rule of the grammar, with room for the locations
of
ruleSize production items (i.e. terminals or non-terminals) |
protected LexBuffer.Position |
getEndPos() |
protected LexBuffer.Position |
getEndPos(int i)
Items are numbered from 1, and include all terminals and
non-terminals, bound or not.
|
protected LexBuffer.Position |
getEndPos(String id) |
protected LexBuffer.Position |
getStartPos() |
protected LexBuffer.Position |
getStartPos(int i)
Items are numbered from 1, and include all terminals and
non-terminals, bound or not.
|
protected LexBuffer.Position |
getStartPos(String id) |
protected LexBuffer.Position |
getSymbolStartPos()
In comparison to
getStartPos() , this is often a better
representation of the production's starting position when the
first items in a production can match the empty string. |
protected void |
leave(@Nullable String name)
Reduces the current top-level rule, which means that the
the stack's current top-level element is popped from the
stack and its overall range is appended to the stack's
new top-level element.
|
protected void |
rewind()
Rewinds the current rule at the top of the location stack,
meaning that the positions will be overwritten as new tokens
are shifted.
|
protected void |
shift(@Nullable String name)
Shifts the last consumed token, which means its position
will be registered on the location stack's current top-level
element.
|
eat, parsingError, peek, tokenError
@DolmenInternal protected final void enter(int ruleSize)
ruleSize
production items (i.e. terminals or non-terminals)ruleSize
- @DolmenInternal protected final void shift(@Nullable String name)
name
.name
- the name to which this terminal is bound in
the rule, or null
if it is not bound@DolmenInternal protected final void leave(@Nullable String name)
name
.name
- the name to which this non-terminal is bound in
the rule, or null
if it is not bound@DolmenInternal protected final void rewind()
protected final LexBuffer.Position getStartPos()
protected final LexBuffer.Position getEndPos()
protected final LexBuffer.Position getSymbolStartPos()
getStartPos()
, this is often a better
representation of the production's starting position when the
first items in a production can match the empty string.protected final LexBuffer.Position getStartPos(int i)
i
- i
-th item
in the parsed productionprotected final LexBuffer.Position getEndPos(int i)
i
- i
-th item
in the parsed productionprotected final LexBuffer.Position getStartPos(String id)
id
- id
in the parsed productionprotected final LexBuffer.Position getEndPos(String id)
id
- id
in the parsed production