-
Notifications
You must be signed in to change notification settings - Fork 0
Literal
xtay2 edited this page Mar 15, 2023
·
7 revisions
The Literal
represents a terminal string in an EBNF which is a symbol that cannot be further decomposed into smaller sections. To initialise it, call the constructor with a literal String
. It gets used for all kinds of symbols and keywords.
-
Literal(char literal)
:- Converts the char to a string
- Calls constructor 3.
-
Literal(Function<String, TerminalToken> tokenFactory, char literal)
:- Converts the char to a string
- Calls constructor 4.
-
Literal(String literal)
:- Strips the literal
-
tokenize()
Produces a TerminalToken when matched
-
Literal(Function<String, TerminalToken> tokenFactory, String literal)
:- Strips the literal
-
tokenize()
calls the tokenFactory when matched
new Literal("abc");
Matches
"abc"
" abc "
" abc"
Fails
"ab c"
"ab"
"Hello"