All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.unlaxer.tinyexpression.parser.MethodInvocationParser Maven / Gradle / Ivy

There is a newer version: 1.4.4
Show newest version
package org.unlaxer.tinyexpression.parser;

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 Parsers getLazyParsers() {
    return new Parsers(
        //ここをoptionalにするとparseが意図しない結果となる。
//        new Optional(
            Parser.get(MethodInvocationHeaderParser.class),
//        ),
        Parser.get(IdentifierParser.class),
        Parser.get(LeftParenthesisParser.class),
        new Optional(
            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 - 2024 Weber Informatics LLC | Privacy Policy