java.lang.Object
java.lang.Record
com.darkcollective.relix.lang.ast.Script
Record Components:
namespace - the declared namespace, or empty if the namespace keyword was absent (the semantic layer treats absent as "default")
statements - the ordered list of top-level statements; never null, may be empty
comments - the comments the parsed text carried, placed by the statements they were written next to, for ScriptPrinter to put back; ScriptComments.NONE for a script that was not parsed
warnings - 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 Details

    • Script

      public Script(Optional<String> namespace, List<Statement> statements, ScriptComments comments, List<ParseWarning> warnings)
      Creates an instance of a Script record class.
      Parameters:
      namespace - the value for the namespace record component
      statements - the value for the statements record component
      comments - the value for the comments record component
      warnings - the value for the warnings record component
    • Script

      public Script(Optional<String> namespace, List<Statement> statements, ScriptComments comments)
      A script with its comments and no warnings.
      Parameters:
      namespace - the declared namespace, or empty
      statements - the statements, in order
      comments - the comments, placed by statement
    • Script

      public Script(Optional<String> namespace, List<Statement> statements)
      A script with no comments: one built from statements rather than parsed.
      Parameters:
      namespace - the declared namespace, or empty
      statements - the statements, in order
  • Method Details

    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • namespace

      public Optional<String> namespace()
      Returns the value of the namespace record component.
      Returns:
      the value of the namespace record component
    • statements

      public List<Statement> statements()
      Returns the value of the statements record component.
      Returns:
      the value of the statements record component
    • comments

      public ScriptComments comments()
      Returns the value of the comments record component.
      Returns:
      the value of the comments record component
    • warnings

      public List<ParseWarning> warnings()
      Returns the value of the warnings record component.
      Returns:
      the value of the warnings record component