Interface ParserComponent


public interface ParserComponent
Represents a parser able to process a single, specific token type
  • Method Details

    • mapString

      static ParserComponent mapString(String name, Function<String,Object> func)
      Creates a ParserComponent that operates on the String value of a token
      Parameters:
      name - The name of the token type to target
      func - The function to parse the String value
      Returns:
      A ParserComponent
    • mapChildren

      static ParserComponent mapChildren(String name, Function<Object[],Object> func)
      Creates a ParserComponent that operates on the parsed Objects of its child tokens
      Parameters:
      name - The name of the token type to target
      func - The function to parse the result from the parsed Objects of child tokens
      Returns:
      A ParserComponent
    • mapToken

      static ParserComponent mapToken(String name, Function<Token,Object> func)
      Creates a ParserComponent that operates directly on a token
      Parameters:
      name - The name of the token type to target
      func - The function to parse the result from the Token object
      Returns:
      A ParserComponent
    • coerce

      static <T> ParserComponent coerce(ParserComponent.ComponentType type, String name, Function<T,Object> func)
    • parse

      Object parse(Object context)
      Parses an Object
      Parameters:
      context - The context Object, depends on the type of the ParserComponent
      Returns:
      The parsed Object
    • getType

      Returns:
      The type of the ParserComponent, which determines what context will be passed to it
    • getName

      String getName()
      Returns:
      The name of the token type targeted by this ParserComponent