org.unlaxer.tinyexpression.parser.MethodInvocationParser Maven / Gradle / Ivy
package org.unlaxer.tinyexpression.parser;
import java.util.List;
import org.unlaxer.Token;
import org.unlaxer.parser.Parser;
import org.unlaxer.parser.Parsers;
import org.unlaxer.parser.ascii.LeftParenthesisParser;
import org.unlaxer.parser.ascii.RightParenthesisParser;
import org.unlaxer.parser.clang.IdentifierParser;
import org.unlaxer.parser.combinator.Optional;
import org.unlaxer.tinyexpression.parser.javalang.JavaStyleDelimitedLazyChain;
import org.unlaxer.util.annotation.TokenExtractor;
public class MethodInvocationParser extends JavaStyleDelimitedLazyChain{
public static boolean enabled1 = true;
public static boolean enabled2 = true;
public static boolean enabled3 = true;
@Override
public List getLazyParsers() {
return new Parsers(
//ここをoptionalにするとparseが意図しない結果となる。
// new Optional(
Parser.get(MethodInvocationHeaderParser.class),
// ),
Parser.get(IdentifierParser.class),
Parser.get(LeftParenthesisParser.class),
new Optional(
Parser.get(ArgumentsParser.class)
),
Parser.get(RightParenthesisParser.class)
);
}
@TokenExtractor
public static java.util.Optional getParametersClause(Token thisParserParsed) {
Parser.checkTokenParsedBySpecifiedParser(thisParserParsed, MethodInvocationParser.class);
return thisParserParsed.getChildWithParserAsOptional(ArgumentsParser.class); //4
}
@TokenExtractor
public static Token getMethodName(Token thisParserParsed) {
Parser.checkTokenParsedBySpecifiedParser(thisParserParsed, MethodInvocationParser.class);
return thisParserParsed.getChildWithParser(IdentifierParser.class); //4
}
public static String getMethodNameAsString(Token thisParserParsed) {
return getMethodName(thisParserParsed).getToken().get();
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy