Package eu.bandm.tools.formattext
Interface CommonParser
public interface CommonParser
Specifies the methods which are implemented by the common
parser to be called-back by the custom parser.
(( ?? FIXME Additionally the min parser function itself)) ????
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept()Consume the current token and fetch the next one to be the current token.voidService for the custom layer to send messages to the same target as the common layer.Return the text content of the current token.Return the type of the current token.booleanReturn whether the next token as the given type.location()Return the location informatio of the current token.static CommonParsernewInstance(MessageReceiver<SimpleMessage<String>> msg, Collection<TokenRule<TokenType>> customTokenRules) Yields a new instance of an implementation.number()Accepts an integer number text representation and returns it conversion result.Parse the given source test.voidsetCustomParser(CustomParser customParser) Set the custom-level parser, so that it can be called by the common parser, whenever the syntax requires it.
-
Field Details
-
SWITCH_DEFAULT_TOKENTYPE
The token type which leads-in the default case in a switch statement. -
SWITCH_DEFAULT_TERMINAL
The terminal symbol which leads-in the default case in a switch statement.- See Also:
-
-
Method Details
-
newInstance
static CommonParser newInstance(MessageReceiver<SimpleMessage<String>> msg, Collection<TokenRule<TokenType>> customTokenRules) Yields a new instance of an implementation.(This allows technically that the implementing class is not known by a client classes = a custom compiler.)
- Parameters:
msg- the target of all generated errors and warnings.customTokenRules- additional token rules from the custom layer.- Returns:
- an instance of an implementation of this interface.
-
parse
Parse the given source test.- Parameters:
source- to be parsedsourceIndication- to be used in the document id of all messages.- Returns:
- the model element which represents the parsed result, or null in case of errors.
-
error
Service for the custom layer to send messages to the same target as the common layer.- Parameters:
loc- the source text location of the errortext- the message text.args- the arguments to evaluate the text byString.format(java.lang.String, java.lang.Object...).
-
la
Return whether the next token as the given type.- Parameters:
tokenType- to test for- Returns:
- whether the next token as the given type.
-
accept
void accept()Consume the current token and fetch the next one to be the current token. -
number
Accepts an integer number text representation and returns it conversion result. If no such token is current, return null. Sends an error if the numeric value cannot be conerted to an "int" primitive type.- Returns:
- the parsed number, or null if the current input does not stand for a valid number.
-
setCustomParser
Set the custom-level parser, so that it can be called by the common parser, whenever the syntax requires it.- Parameters:
customParser- the custom-level parser to be called by the common parser, whenever the syntax requires it.
-
location
Return the location informatio of the current token.- Returns:
- the location informatio of the current token.
-
getTokenText
String getTokenText()Return the text content of the current token.- Returns:
- the text content of the current token.
-
getTokenType
TokenType getTokenType()Return the type of the current token.- Returns:
- the type of the current token.
-