Package ortus.boxlang.compiler.parser
Class Parser
java.lang.Object
ortus.boxlang.compiler.parser.Parser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClear the DFA cache across all parsers.static BoxSourceTypedetectFile(File file) Attempt to detect the type of source code based on the contentsstatic intGet the number of states stored in all the DFA cache across all parsers.getFileExtension(String filename) Parse a script fileparse(String code, BoxSourceType sourceType) Parse a script string expressionparse(String code, BoxSourceType sourceType, Boolean classOrInterface) Parse a script string expressionparseExpression(String code) Parse a script string statementparseStatement(String code)
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
parse
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
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
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
- Throws:
IOException
-
detectFile
Attempt to detect the type of source code based on the contents- Parameters:
file- File to check- Returns:
- a BoxFileType
- See Also:
-
getFileExtension
-
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.
-