public class MemScanner extends MemString
MemString
objects.
lastTokenType
,
lastContent
, etc. describe the last recognized input token.
This extends up to MemString.start
, which is the "next-to-decode"
reading position.
accept()
means that the current result info has been
consumed by the calling layer. So it is forgotten, the next token
is decoded at the next-to-read adress, this address is advanced, and all
result fields are updated.
Modifier and Type | Class and Description |
---|---|
static class |
MemScanner.OpenTagModifier |
static class |
MemScanner.TokenType |
MemString.CharMem, MemString.ReadBehindBufferEndException, MemString.Reader
Modifier and Type | Field and Description |
---|---|
protected String |
closedTag
output parameter, full-text tag in case of lastTokenType=closeChar
|
protected char |
commandchar
Local state which can be altered by the caller.
|
protected char |
commentchar_1
Local state which can be altered by the caller.
|
protected String |
commentstring_ml |
protected String |
commentstring_sl |
protected Character |
current_toplevel_end
cache for top-most closing parenthesis, for performance only.
|
protected Stack<Location<String>> |
endlocations
internal state, holding the positions of the paren's activation.
|
protected Stack<Character> |
endparentheses
internal state, holding the currently expected parentheses
|
protected Stack<String> |
endtags
internal state, holding the full text tags corresponding to parenths.
|
protected MemString |
lastContent
output parameter, holding the character content consumed as last
|
protected int |
lastNumericValue
output parameter
|
protected MemScanner.TokenType |
lastTokenType
output parameter
|
static CharSet |
nonBlank |
CHAR_EOTEXT, CHAR_NEWLINE, colnum, data, len, linenum, start
Constructor and Description |
---|
MemScanner(MemString.CharMem m) |
MemScanner(MemString m) |
Modifier and Type | Method and Description |
---|---|
void |
accept_blanks_filtered()
Called from
CharacterParser and
from Text2Udom ONCE before character and enumeration parsing starts. |
void |
accept_blanks_noCommentsAllowed()
commandchar, commentchar, eof and parenthesis chars are never contained
in any def of "whitespace characters".
|
int |
accept_greedy_filtered_chars(CharSet set)
Only called (only once) from
CharacterParser . |
boolean |
accept_one_filtered_char(CharSet set)
Only called from CharacterParser.
|
boolean |
accept_one(char c)
Only called from
Text2Udom when decoding file header. |
boolean |
accept_one(CharSet cs) |
boolean |
accept_string_w_o_lineswitch(String s)
Assume String s does NOT contain any line switching characters!
FIXME this must be checked in char parser type checker of STRING The string is accepted if it is continuously contained outside of comment, AND does not contain the current top-level close paranethesis character. The command char is currently not rejected, i.e. |
void |
accept()
Central scanning procedure: (1) throws away old results, (2) consumes more
characters and (3) sets
get_lastTokenType() , last_content ,
get_lastLocation() etc. |
MemScanner |
copy()
returns a clone.
|
Character |
endTagCharacter(String tag)
Returns the currently expected first "close parenthesis" character.
|
MemString |
get_lastContent()
interface procedure: deliver MemString lastly consumed.
|
Location<String> |
get_lastLocation()
interface procedure: character location lastly consumed.
|
MemScanner.TokenType |
get_lastTokenType()
interface procedure: deliver token type of last consumption act.
|
int |
get_numericValue()
interface procedure: deliver numeric tag (for direct unicode access!).
|
char |
getCommandChar() |
char |
getCommentChar_1()
"comment char 2" is fixed to "*" in
Chars.CHAR_COMMENT_2 . |
Location<String> |
getParenthesisDefinitionLocation(String tag)
ONLY called from warning for pending/possibly unused closed par!
|
MemScanner.OpenTagModifier |
markParenthesis(String tag)
consume an open parenthesis and memoize its counterpart.
|
Location<String> |
popParenthesis()
May only be called when a close-par has been signalled as recognized!
|
String |
read_ident_or_null()
Only called from
Text2Udom when decoding file header. |
String |
read_nonblank()
Only called from
Text2Udom when decoding file header. |
char |
scan_again_skipping_first()
HACK: reset state of parser, as it was before the last "accept", but
skip the first character of the last recognized result.
|
void |
setCommandChar(char c)
Interface procedure: change command char.
|
void |
setCommentChar_1(char c)
Interface procedure: change comment char.
|
void |
skip_after_char(char c)
ASSUMEs that character is really present.
|
void |
skip_until_eoline()
Is called from Text2Udom digest_nothing_open() and digest_consume_characters(),
when a "///" = "incomplete close" token has been consumed in the role of a
comment start.
|
adjustLineNumberX, advance, advanceBy, advanceByX_sameLine, advanceX, appendAll, asString, backwardsX, backwardsX, calccolnum, clearLineX, equals, get_colnum, get_data, get_len, get_linenum, get_start, getChar, getChar, getFollowLocation, getLocation, getNextLine, getNextLineX, getPositionIndication, initFrom, isPrefixedBy, main, putChar, toString, upTo, upToX
protected MemScanner.TokenType lastTokenType
protected int lastNumericValue
protected MemString lastContent
protected String closedTag
protected Stack<Character> endparentheses
protected Stack<String> endtags
protected Stack<Location<String>> endlocations
protected Character current_toplevel_end
protected char commandchar
protected char commentchar_1
Chars.CHAR_COMMENT_2
.protected String commentstring_sl
protected String commentstring_ml
public static final CharSet nonBlank
public MemScanner(MemString m)
public MemScanner(MemString.CharMem m)
public MemScanner copy()
MemString
public MemScanner.OpenTagModifier markParenthesis(String tag)
accept()
..
Consumes one(1) char if it is an open-par, and memoizes the
closing one. Consumes one(1) char if it is a whitespace !
# tag CONTINUE TEXT # tag/CONTINUE TEXT # tag///CONTINUE TEXT # tag//comment recognizes as such(incl lead in!) # tag CONTINUE TEXT # tag(continue text with parenthesis open # tag=continue text including leading special, non-paren char # tag()xx same as #tag/xx
public Location<String> popParenthesis()
public Character endTagCharacter(String tag)
public Location<String> getParenthesisDefinitionLocation(String tag)
public void setCommandChar(char c)
public void setCommentChar_1(char c)
public char getCommandChar()
public char getCommentChar_1()
Chars.CHAR_COMMENT_2
.public MemScanner.TokenType get_lastTokenType()
public MemString get_lastContent()
public int get_numericValue()
public Location<String> get_lastLocation()
public void accept()
get_lastTokenType()
, last_content
,
get_lastLocation()
etc. accordingly.
Never fails. "///" --> forced end quote otherwise "//" --> one-line comment start (if comment char has not been altered.) otherwise "/" --> end quoteNOTES:
public char scan_again_skipping_first()
Text2Udom#commandchar()
and Text2Udom#commentchar()
,
otherwise the standard "accept()" interface would become much
more complicated !public void skip_until_eoline()
public void skip_after_char(char c)
ReadBehindBufferEndException
.
Only called (once) in Text2Udom
, when parsing header.public int accept_greedy_filtered_chars(CharSet set)
CharacterParser
.
Comments and parenthesis chars have priority over character parsers.
The current command character is accepted when in the parser def the
standard command character appears.public boolean accept_one_filtered_char(CharSet set)
public void accept_blanks_filtered()
CharacterParser
and
from Text2Udom
ONCE before character and enumeration parsing starts.public void accept_blanks_noCommentsAllowed()
Text2Udom
when decoding file header.
There no comments may appear.public String read_ident_or_null()
Text2Udom
when decoding file header.public boolean accept_one(char c)
Text2Udom
when decoding file header.
(comments are not allowed there) DOCU FIXME)public boolean accept_one(CharSet cs)
public boolean accept_string_w_o_lineswitch(String s)
CharacterParser
for "String" expressions,
by Text2Udom
when parsing the file header, and when parsing an Enumeration value.see also the complete user documentation .