Package eu.bandm.tools.d2d2.parser2
Class TLex<D,T>
java.lang.Object
eu.bandm.tools.d2d2.parser2.TLex<D,T>
- All Implemented Interfaces:
Supplier<Parser.Token<D,
T>>
Item continuation Item action (TLex context) | ConsumeOrShift c char cset CharSet actionAfterTest(TLex context) | | Consume | | Shift | ChoiceOrState alternatives SEQ ConsumeOrShift other OPT Otherwise actionAfterTest(TLex context) | | Choise | | State | Other | CloseState | Append text OPT string | Deliver reduce OPT Function t TokenType | Text2Token fun BiFunction<String,Location,Tokentype> | Text2cont fun BiFunction<String,Location,Tokentype> | Error text String
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Append the given text or the last consumed character to TLex.outBufferstatic class
Steps through all alternatives (which must be Consumes or Shifts) and calls their "test()" and "actionAfterText()" separately.static class
static class
static class
If the test is positive (look-ahead char is equal to c or is in set cset) then consume this character = remove it from the input and get the next look-ahead.static class
static class
Constructcs a token with the given type and the text accumulated in "TLex.outBuffer" and the location from "TLex.location()".static interface
Can be implemented by a token type to get a printable text.static class
Delivers a token with the error token type (as defined when constructing TLex) and the given type.static class
static class
Only a wrapper needed for the construction interface.static class
If the test is positive (look-ahead char is equal to c or is in set cset) then append this character to the output buffer "Tlex.oputBuffer" and consume this character.static class
Pushes itself onto the stateStack and the current input location to the locstack.static class
Calculates the contiunation (=the following lexer code) from the vaue accumulated in the TLex.outBuffer.static class
Same as deliver, but not the token factory stord in TLex but the function is used for constructing the token.static class
TLex.Token<D,
T extends TLex.Displayable> A simple default implementation of Tokens. -
Field Summary
Modifier and TypeFieldDescriptionstatic final TunableParser.CharSet
static final TunableParser.CharSet
static final TunableParser.CharSet
static final TunableParser.CharSet
static final TunableParser.CharSet
static final TunableParser.CharSet
static final TunableParser.CharSet
ATTENTION includes backspace according to Java definitions.protected static final String
protected final T
protected final T
protected StringBuilder
protected Parser.Token<D,
T> protected Stack<TLex.State<D,
T>> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <DD,
TT> TLex.Append<DD, TT> append()
static <DD,
TT> TLex.Append<DD, TT> static <DD,
TT> TLex.Append<DD, TT> static <DD,
TT> TLex.Append<DD, TT> static <DD,
TT> TLex.Choice<DD, TT> static <DD,
TT> TLex.CloseState<DD, TT> static <DD,
TT> TLex.CloseState<DD, TT> closeState
(TLex.Item<DD, TT> continuation) static <DD,
TT> TLex.CloseState<DD, TT> closeStates
(@Opt TLex.Item<DD, TT> cont, int times) static <DD,
TT> TLex.Item<DD, TT> comments
(TT singleLine, TT multiLine, TT singleSlash) Accepts and returns a standard C-/Java-style single line comment.static <DD,
TT> TLex.Consume<DD, TT> consume()
static <DD,
TT> TLex.Consume<DD, TT> consume
(char c) static <DD,
TT> TLex.Consume<DD, TT> static <DD,
TT> TLex.Consume<DD, TT> consume
(char c, TT type) static <DD,
TT> TLex.Consume<DD, TT> static <DD,
TT> TLex.Consume<DD, TT> static <DD,
TT> TLex.Consume<DD, TT> consume
(TunableParser.CharSet cs, @Opt TLex.Item<DD, TT> continuation) static <DD,
TT> TLex.Deliver<DD, TT> deliver
(TT t) static <DD,
TT> TLex.Deliver<DD, TT> static <DD,
TT> TLex.Error<DD, TT> get()
Operation: As long as no token as yet been recognized, the item in the field "TLex.continuation" is executed, i.e.static <DD,
TT> TLex.Item hexNumber
(TT hexnumberTokenType) Recognizes and reduces hexadecimal constant of form "0x[d]" and "0X[d]".static <DD,
TT> TLex.Other<DD, TT> other()
static <DD,
TT> TLex.Other<DD, TT> void
static <DD,
TT> TLex.Shift<DD, TT> shift()
static <DD,
TT> TLex.Shift<DD, TT> shift
(char c) static <DD,
TT> TLex.Shift<DD, TT> static <DD,
TT> TLex.Shift<DD, TT> static <DD,
TT> TLex.Shift<DD, TT> static <DD,
TT> TLex.Shift<DD, TT> shift
(TunableParser.CharSet cs, @Opt TLex.Item<DD, TT> continuation) static <DD,
TT> TLex.State<DD, TT> static <DD,
TT> TLex.Item<DD, TT> stringconst
(char delim, TT tt) Accepts and returns a standard string constant, containing standard escape sequences.static <DD,
TT> TLex.Text2cont<DD, TT> text2cont
(BiFunction<String, Location<DD>, TLex.Item<DD, TT>> fun) Applies a user function to the accumulated text.static <DD,
TT> TLex.Text2token<DD, TT> text2token
(BiFunction<String, Location<DD>, Parser.Token<DD, TT>> fun) Applies a user function to the accumulated text.static <DD,
TT> TLex.Text2token<DD, TT> text2token
(BiFunction<String, Location<DD>, Parser.Token<DD, TT>> fun, @Opt TLex.Item<DD, TT> continuation) static final <DD,
TT> Supplier<Parser.Token<DD, TT>> tokenIgnorer
(Supplier<Parser.Token<DD, TT>> lexer, TT... toIgnore) static <DD,
TT> TLex.State<DD, TT> verbatimEnd
(TT tt, String post, @Opt TLex.Item<DD, TT> continuation) Accepts a verbatim input character sequence ended by a particular string constant.static <DD,
TT> TLex.Consume<DD, TT> verbatimLike
(TT tt, String pre, String post) Accepts token contents delimited by two string, like the LaTeX "verbatim" command.
-
Field Details
-
topLexer
-
input
-
tokenFactory
-
errorTokenType
-
eofTokenType
-
continuation
-
result
-
stateStack
-
locStack
-
outBuffer
-
stuckText
-
defaultStuckText
- See Also:
-
cs_ws
ATTENTION includes backspace according to Java definitions. -
cs_hexDigit
-
cs_decDigit
-
cs_decDigit_1_9
-
cs_identStart
-
cs_identPart
-
cs_all
-
-
Constructor Details
-
TLex
-
-
Method Details
-
setInput
-
get
Operation: As long as no token as yet been recognized, the item in the field "TLex.continuation" is executed, i.e. its "action()" method is called. Every such action copies its own ".continuation" into that field (Cannto be factored out, because State and Choice behave differentyl: the continuation is defined by the selected child element.) If this is ==0, then the continuation is pulled from the stateStack. -
consume
-
consume
-
consume
public static <DD,TT> TLex.Consume<DD,TT> consume(TunableParser.CharSet cs, @Opt @Opt TLex.Item<DD, TT> continuation) -
consume
-
consume
-
consume
-
consume
-
shift
-
shift
-
shift
-
shift
public static <DD,TT> TLex.Shift<DD,TT> shift(TunableParser.CharSet cs, @Opt @Opt TLex.Item<DD, TT> continuation) -
shift
-
shift
-
choice
-
state
-
other
-
other
-
closeState
-
closeState
-
append
-
append
-
append
-
append
-
deliver
-
deliver
-
text2token
public static <DD,TT> TLex.Text2token<DD,TT> text2token(BiFunction<String, Location<DD>, Parser.Token<DD, TT>> fun) Applies a user function to the accumulated text. -
text2token
public static <DD,TT> TLex.Text2token<DD,TT> text2token(BiFunction<String, Location<DD>, Parser.Token<DD, TT>> fun, @Opt @Opt TLex.Item<DD, TT> continuation) -
text2cont
public static <DD,TT> TLex.Text2cont<DD,TT> text2cont(BiFunction<String, Location<DD>, TLex.Item<DD, TT>> fun) Applies a user function to the accumulated text. -
error
-
verbatimLike
Accepts token contents delimited by two string, like the LaTeX "verbatim" command. ATTENTION: Repetitions of characters in the limiting strings are not supported. The automaton built by verbatimLike("ab","yz") has the following structure:CL() stands for closeState() in: consume('a',state(consume('b', state(consume('y',state(consume('z',CL(CL(CL(deliver(tt))))), other(append('y',shift(CL))) )), other(shift()) ), other(append('a',CL())) )))
The resulting automaton shall be included in a choice() or state() disjunction.
ATTENTION NOT YET TESTED, never used. -
verbatimEnd
public static <DD,TT> TLex.State<DD,TT> verbatimEnd(TT tt, String post, @Opt @Opt TLex.Item<DD, TT> continuation) Accepts a verbatim input character sequence ended by a particular string constant. ATTENTION: Repetitions of characters in the limiting string are not supported. The automaton built by verbatimLike("ab","yz") has the following structure:CL() stands for closeState() in: state(consume('y',state(consume('z',CL(CL(deliver(tt, cont)))), other(append('y',shift(CL))) )), other(shift()) )
-
closeStates
public static <DD,TT> TLex.CloseState<DD,TT> closeStates(@Opt @Opt TLex.Item<DD, TT> cont, int times) -
tokenIgnorer
@SafeVarargs public static final <DD,TT> Supplier<Parser.Token<DD,TT>> tokenIgnorer(Supplier<Parser.Token<DD, TT>> lexer, TT... toIgnore) -
hexNumber
Recognizes and reduces hexadecimal constant of form "0x[d]" and "0X[d]". [d] stands for an arbitrary, finite, non-empty sequence of hexadeimal digits, upper or lower case. -
comments
Accepts and returns a standard C-/Java-style single line comment. PROVIS FIXME "singleSlash" should be replaced by merging the choices one level above! -
stringconst
Accepts and returns a standard string constant, containing standard escape sequences. FIXME welche escapes in singlequote/doublequote !?!? Parametrisierbar ??
-