|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.quasiliteral.syntax.Indenter
Untamed: Keeps track of indentation info for BaseLexer's subclasses and clients.
Field Summary | |
private char[] |
myCloserStack
The closers -- close bracketing characters that would close the currently unclosed open brackets |
private int[] |
myIndentStack
The indentation level associated with each unclosed open bracket |
private int |
myNest
How many block-levels deep am I? |
private boolean[] |
myNestStack
Was this open bracket also a nesting? |
private Twine[] |
myOpennerStack
The openners are Twine for reporting located errors at close time |
private int |
myTOS
My top-of-stack is the same as the number of unclosed open bracketing characters. |
Constructor Summary | |
Indenter()
Enabled: |
Method Summary | |
int |
getCloseIndent()
Enabled: If the character that would close the most recently open bracket (getCloser()) were typed, where should it be indented? |
char |
getCloser()
Enabled: Which character would close the most recent open bracket? |
int |
getIndent()
Enabled: How indented should a vanilla new line be in this context? |
private Object |
grow(Object array)
|
void |
nest(Twine openner,
char closerChar)
Enabled: Push a nester |
void |
pop(char closerChar,
Twine closer)
Enabled: Process a closing bracket by popping the stacks. |
void |
popIf(char closerChar)
Enabled: If the tos is closerChar, then process a closing bracket by popping the stacks. |
void |
push(Twine openner,
char closerChar,
int indent)
Enabled: Push a non-nester |
private void |
push(Twine openner,
char closerChar,
int indent,
boolean isNest)
Internal push |
void |
requireEmpty(String msg)
Enabled: |
String |
toString()
Suppressed: Show closing stack |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private int myNest
Each open-bracketing character at the end of a line introduces a new nesting level. Each nesting level counts for four spaces.
private int myTOS
The stack keeps track of unclosed open brackets, and what indent should be assigned to new lines within that bracket (should it be the most recent -- the top of stack).
private Twine[] myOpennerStack
private char[] myCloserStack
We start the stack off with an indent level of zero and a dummy closer character.
private int[] myIndentStack
private boolean[] myNestStack
I.e., was the openner the last character on its line? If so, then its popping should also decrement myNest.
Constructor Detail |
public Indenter()
Method Detail |
private Object grow(Object array)
private void push(Twine openner, char closerChar, int indent, boolean isNest)
public void nest(Twine openner, char closerChar)
public void push(Twine openner, char closerChar, int indent)
public void pop(char closerChar, Twine closer)
If the opening was also a nesting, this decrements the nest level.
closerChar
- As an error check, 'closerChar' must be the closing
bracket character needed to close the most recent
unclosed bracket.closer
- Used by some syntax errors to report where the erronous
closing text occurs.public void requireEmpty(String msg)
public void popIf(char closerChar)
If the opening was also a nesting, this decrements the nest level.
closerChar
- Checks whether 'closerChar' is the closing
bracket character needed to close the most recent
unclosed bracket.public int getIndent()
A vanilla new line is one that doesn't begin with a close bracketing character (for these, use pop()'s return value), and one that's not continuing a previous line by virtue of a binary operator or a backslash
public char getCloser()
public int getCloseIndent()
public String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |