|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.syntax.parser.ExpressionStack
A combination stack and helper class for parsing groovy expression.
Expressions are a little trickier to parse than the statements above. As a result, we are now doing a hybrid LL/LR parse at the expression level.
Field Summary | |
private int |
open
|
private Parser |
parser
|
private java.util.ArrayList |
stack
|
Constructor Summary | |
(package private) |
ExpressionStack(Parser context)
|
Method Summary | |
(package private) boolean |
atStartOfExpression()
Return true if the stack is at the start of an expression. |
boolean |
canComplete()
Returns true if the stack can be completed without further shifts. |
boolean |
isComplete()
Returns true if the stack is in a state that can be considered a complete expression, provided lookahead is amenable, of course. |
(package private) boolean |
isEmpty()
Returns true if the stack is empty. |
(package private) CSTNode |
pop()
Pops the node from the top of the stack. |
(package private) void |
push(CSTNode node)
Pushes a node onto the stack. |
(package private) void |
reduce(int count,
int rootOffset,
boolean mark)
Performs a reduce by taking some number of CSTNode s
from the top of the stack, and making one of them a
Reduction with the others as children, then pushes
that new node back onto the stack. |
(package private) void |
shift()
Shifts a token from the stream to the top of the stack. |
(package private) void |
shift(int count)
Shifts some number of (non-newline) tokens from the stream to the top of the stack. |
(package private) void |
shiftIf(boolean flag,
java.lang.String error)
Shifts if the specified flag is true, reports an error otherwise. |
(package private) void |
shiftIfTopIsAnExpression(java.lang.String error)
Shifts if the top of the stack is an expression, reports an error otherwise. |
(package private) void |
shiftIfTopIsAnOperator(java.lang.String error)
Shifts if the top of the stack is a operator, reports an error otherwise. |
(package private) void |
shiftUnless(boolean flag,
java.lang.String error)
Shifts unless the specified flag is true, reports an error otherwise. |
(package private) void |
shiftUnlessTopIsAnExpression(java.lang.String error)
Shifts unless the top of the stack is an expression, reports an error otherwise. |
(package private) void |
shiftUnlessTopIsAnOperator(java.lang.String error)
Shifts unless the top of the stack is an operator, reports an error otherwise. |
(package private) int |
size()
Returns the number of elements in the stack. |
(package private) CSTNode |
top()
Returns the top node from the stack without removing it. |
(package private) CSTNode |
top(int offset)
Returns some node from the stack. |
(package private) boolean |
topIsAModifiableExpression()
Returns true if the top element of the stack is a modifiable expression. |
(package private) boolean |
topIsAnExpression()
Returns true if the top element of the stack is an expression. |
(package private) boolean |
topIsAnOperator()
Returns true if the top element of the stack is an operator. |
(package private) boolean |
topIsAnOperator(int offset,
boolean unknownReturns)
Returns true if the element at the specified offset from the top of the stack is an operator. |
java.lang.String |
toString()
Creates a string representation of the stack. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.util.ArrayList stack
private Parser parser
private int open
Constructor Detail |
ExpressionStack(Parser context)
Method Detail |
boolean isEmpty()
public boolean isComplete()
public boolean canComplete()
int size()
void push(CSTNode node)
CSTNode pop()
CSTNode top()
CSTNode top(int offset)
offset
is counted
from the top of the stack.
void shift(int count) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
void shift() throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
void reduce(int count, int rootOffset, boolean mark)
CSTNode
s
from the top of the stack, and making one of them a
Reduction
with the others as children, then pushes
that new node back onto the stack.
boolean atStartOfExpression()
boolean topIsAnOperator()
boolean topIsAnOperator(int offset, boolean unknownReturns)
boolean topIsAModifiableExpression()
boolean topIsAnExpression()
void shiftIf(boolean flag, java.lang.String error) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
void shiftUnless(boolean flag, java.lang.String error) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
void shiftIfTopIsAnExpression(java.lang.String error) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
void shiftIfTopIsAnOperator(java.lang.String error) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
void shiftUnlessTopIsAnExpression(java.lang.String error) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
void shiftUnlessTopIsAnOperator(java.lang.String error) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |