Record Class Script
java.lang.Object
java.lang.Record
com.darkcollective.relix.lang.ast.Script
- Record Components:
namespace- the declared namespace, or empty if thenamespacekeyword was absent (the semantic layer treats absent as"default")statements- the ordered list of top-level statements; never null, may be emptycomments- the comments the parsed text carried, placed by the statements they were written next to, forScriptPrinterto put back;ScriptComments.NONEfor a script that was not parsedwarnings- the slips the parser accepted in the text, in the order written, which analysis reports as warnings; empty for a script that was not parsed
public record Script(Optional<String> namespace, List<Statement> statements, ScriptComments comments, List<ParseWarning> warnings)
extends Record
The root AST node for a parsed
.relix script file.
A script is an ordered sequence of Statements, optionally prefixed
by a namespace declaration. The namespace defaults to "default"
if absent.
Example source and its AST:
namespace weather;
env from './.relix-env.json' using 'development';
import source current_weather from './weather-api.relix';
query { σ city = "Chicago, IL" (current_weather) };
produces:
Script(
namespace = Optional.of("weather"),
statements = [
EnvStatement(...),
ImportStatement(SOURCE, ["current_weather"], "./weather-api.relix"),
QueryStatement(ExpressionQueryTarget(...))
]
)
-
Constructor Summary
ConstructorsConstructorDescriptionA script with no comments: one built from statements rather than parsed.A script with its comments and no warnings.Script(Optional<String> namespace, List<Statement> statements, ScriptComments comments, List<ParseWarning> warnings) Creates an instance of aScriptrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncomments()Returns the value of thecommentsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thenamespacerecord component.Returns the value of thestatementsrecord component.final StringtoString()Returns a string representation of this record class.warnings()Returns the value of thewarningsrecord component.
-
Constructor Details
-
Script
public Script(Optional<String> namespace, List<Statement> statements, ScriptComments comments, List<ParseWarning> warnings) Creates an instance of aScriptrecord class.- Parameters:
namespace- the value for thenamespacerecord componentstatements- the value for thestatementsrecord componentcomments- the value for thecommentsrecord componentwarnings- the value for thewarningsrecord component
-
Script
A script with its comments and no warnings.- Parameters:
namespace- the declared namespace, or emptystatements- the statements, in ordercomments- the comments, placed by statement
-
Script
A script with no comments: one built from statements rather than parsed.- Parameters:
namespace- the declared namespace, or emptystatements- the statements, in order
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
namespace
Returns the value of thenamespacerecord component.- Returns:
- the value of the
namespacerecord component
-
statements
Returns the value of thestatementsrecord component.- Returns:
- the value of the
statementsrecord component
-
comments
Returns the value of thecommentsrecord component.- Returns:
- the value of the
commentsrecord component
-
warnings
Returns the value of thewarningsrecord component.- Returns:
- the value of the
warningsrecord component
-