org.unlaxer.tinyexpression.parser.MethodParser Maven / Gradle / Ivy
package org.unlaxer.tinyexpression.parser;
import java.util.Optional;
import org.unlaxer.TokenPredicators;
import org.unlaxer.TypedToken;
import org.unlaxer.parser.Parser;
import org.unlaxer.parser.clang.IdentifierParser;
import org.unlaxer.util.annotation.TokenExtractor;
public interface MethodParser extends Parser{
public abstract Class extends TypeHint> returningParser();
public abstract Class extends ExpressionInterface> expressionParser();
@TokenExtractor
public default TypedToken returning(TypedToken thisParserParsed) {
checkTokenParsedByThisParser(thisParserParsed);
TypedToken typedWithInterface = thisParserParsed.getChild(TokenPredicators.parsers(returningParser()))
.typedWithInterface(TypeHint.class);
return typedWithInterface;
}
@TokenExtractor
public default TypedToken methodName(TypedToken thisParserParsed) {
checkTokenParsedByThisParser(thisParserParsed);
return thisParserParsed.getChild(TokenPredicators.parsers(IdentifierParser.class))
.typed(IdentifierParser.class);
}
@TokenExtractor
public default TypedToken methodParameters(TypedToken thisParserParsed) {
checkTokenParsedByThisParser(thisParserParsed);
return thisParserParsed.getChild(TokenPredicators.parsers(MethodParametersParser.class))
.typed(MethodParametersParser.class);
}
@TokenExtractor
public default Optional> typedVariableParser(
TypedToken thisParserParsed , String parameterName) {
TypedToken methodParameters = methodParameters(thisParserParsed);
MethodParametersParser parser = methodParameters.getParser();
Optional> extractTypedVariableParser =
parser.extractTypedVariableParser(methodParameters, parameterName);
return extractTypedVariableParser;
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy