java.lang.Object
com.darkcollective.relix.lang.ScriptParser
Recursive-descent parser for
.relix scripting language source files.
Usage
Script script = ScriptParser.parse(sourceText); Script script = ScriptParser.parse(sourceText, "path/to/file.relix");
Script structure
[namespace IDENTIFIER ;] [env [from STRING] [using STRING] ;] (import | source | connection | relate | IDENTIFIER := ... | def | query) *
Embedded sub-languages
Relational-algebra expression blocks (\{ … \}) in assignment
and query statements are extracted as raw text and delegated eagerly to
RelAlgebraParser.parse(String, String, int, int).
Function-body expressions in def statements are similarly
delegated to RelAlgebraParser.parseOperand(String, String, int, int).
Raw block extraction invariant
When a delimiter token (LangTokenType.LBRACE or
LangTokenType.LBRACKET) is the current lookahead, the lexer's
character position is already past that delimiter character.
Raw block extraction must therefore be performed without
calling advance() first — doing so would skip the first content
character. The LangLexer.consumeRawBraceBlock() and
LangLexer.consumeRawBracketBlock() helpers enforce this contract.-
Method Summary
Modifier and TypeMethodDescriptionstatic Scriptparse(InputStream input) Parses a relix scripting language source from the given input stream (UTF-8 encoded).static Scriptparse(InputStream input, String filePath) Parses a relix scripting language source from the given input stream (UTF-8 encoded), embeddingfilePathin every statement's source location.static ScriptParses a relix scripting language source from the given string.static ScriptParses a relix scripting language source from the given string, embeddingfilePathin every statement's source location.
-
Method Details
-
parse
Parses a relix scripting language source from the given string.- Parameters:
source- the full script source text- Returns:
- the parsed
ScriptAST - Throws:
LangParseException- if the source contains syntax errorsNullPointerException- ifsourceis null
-
parse
Parses a relix scripting language source from the given string, embeddingfilePathin every statement's source location.- Parameters:
source- the full script source textfilePath- the file path to embed in source locations- Returns:
- the parsed
ScriptAST - Throws:
LangParseException- if the source contains syntax errorsNullPointerException- ifsourceorfilePathis null
-
parse
Parses a relix scripting language source from the given input stream (UTF-8 encoded).- Parameters:
input- the source stream- Returns:
- the parsed
ScriptAST - Throws:
IOException- if reading from the stream failsLangParseException- if the source contains syntax errorsNullPointerException- ifinputis null
-
parse
Parses a relix scripting language source from the given input stream (UTF-8 encoded), embeddingfilePathin every statement's source location.- Parameters:
input- the source streamfilePath- the file path to embed in source locations- Returns:
- the parsed
ScriptAST - Throws:
IOException- if reading from the stream failsLangParseException- if the source contains syntax errorsNullPointerException- ifinputorfilePathis null
-