Class Parser

java.lang.Object
redempt.redlex.parser.Parser

public class Parser extends Object
A parser which will parse an input string and convert it according to predefined rules
  • Method Details

    • create

      public static Parser create(Lexer lexer, ParserComponent... components)
      Creates a parser from a lexer and components
      Parameters:
      lexer - The Lexer used to tokenize input
      components - The components used to parse tokens
      Returns:
      A Parser using the given components and lexer
    • getLexer

      public Lexer getLexer()
      Returns:
      The Lexer this Parser wraps
    • parse

      public Object parse(String input, boolean errorOnFail)
      Parses the input string and returns the result
      Parameters:
      input - The string to parse
      errorOnFail - Whether to throw a LexException for invalid format, returns null if false
      Returns:
      The parsed object
    • parse

      public Object parse(String input)
      Parses the input string and returns the result
      Parameters:
      input - The string to parse
      Returns:
      The parsed object