Class Parser

java.lang.Object
ortus.boxlang.compiler.parser.Parser

public class Parser extends Object
  • Constructor Details

    • Parser

      public Parser()
  • Method Details

    • parse

      public ParsingResult parse(File file)
      Parse a script file
      Parameters:
      file - source file to parse
      Returns:
      a ParsingResult containing the AST with a BoxScript as root and the list of errors (if any)
      Throws:
      IOException
      See Also:
    • parse

      public ParsingResult parse(String code, BoxSourceType sourceType) throws IOException
      Parse a script string expression
      Parameters:
      code - source of the expression to parse
      Returns:
      a ParsingResult containing the AST with a BoxExpr as root and the list of errors (if any)
      Throws:
      IOException
      See Also:
    • parse

      public ParsingResult parse(String code, BoxSourceType sourceType, Boolean classOrInterface) throws IOException
      Parse a script string expression
      Parameters:
      code - source of the expression to parse
      Returns:
      a ParsingResult containing the AST with a BoxExpr as root and the list of errors (if any)
      Throws:
      IOException
      See Also:
    • parseExpression

      public ParsingResult parseExpression(String code)
      Parse a script string statement
      Parameters:
      code - source of the expression to parse
      Returns:
      a ParsingResult containing the AST with a BoxStatement as root and the list of errors (if any)
      See Also:
    • parseStatement

      public ParsingResult parseStatement(String code) throws IOException
      Throws:
      IOException
    • detectFile

      public static BoxSourceType detectFile(File file)
      Attempt to detect the type of source code based on the contents
      Parameters:
      file - File to check
      Returns:
      a BoxFileType
      See Also:
    • getFileExtension

      public static Optional<String> getFileExtension(String filename)
    • getCacheSize

      public static int getCacheSize()
      Get the number of states stored in all the DFA cache across all parsers.
      Returns:
      the number of states stored in all the DFA cache
    • clearParseCache

      public static void clearParseCache()
      Clear the DFA cache across all parsers.