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

public record Script(Optional<String> namespace, List<Statement> statements) 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)
      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
  • 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