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

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

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

import java.util.Optional;

import org.unlaxer.Tag;
import org.unlaxer.Token;
import org.unlaxer.TokenPredicators;
import org.unlaxer.TypedToken;
import org.unlaxer.parser.Parser;

public interface VariableParser extends Parser{
  
  public Optional typeAsOptional();
  public default boolean hasType() {
    return typeAsOptional().isPresent();
  }
  
//  public String getVariableName(Token thisParserParsed);
  
  public static Tag variableNameTag = new Tag("variableName");
  
  public default String getVariableName(TypedToken token) {
    Token identifierToken = token.flatten().stream()
      .filter(TokenPredicators.hasTag(variableNameTag))
      .findFirst().get();
    return identifierToken.tokenString.get();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy