Home /Modules/compiler/SLSourceForm.sleela

SLSourceForm.sleela

lib/compiler/SLSourceForm.sleela · 108 line(s) · sleela

<< lib/compiler/SLSourceForm.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLSourceForm, the set of SLeeLa source forms the compiler
     can be asked to compile, so that .sldocument is a first-class compile choice
     alongside ordinary .sleela.
   
   The SLeeLa Compiler accepts more than one source form. This type names each
   form, its canonical extension, and whether it is ordered top-down. The
   compiler's selection model (language -> family -> version -> producer ->
   source form -> IR/object -> target) consults this to pick the right front end.
   
   Forms:
     SLEELA     โ€” the general program/source unit (.sleela), class/method shaped.
     SLDOCUMENT โ€” the ordered, top-down document (.sldocument); annotated method
                  steps run in order, each usually returning one binary value.
     SLSCRIPT   โ€” the dynamic scripting form (.sleela-script).
   
   Family: compiler. Native VM/OS work crosses an explicit bridge. >>
#sleela 2.5
material;
< Unified SLeeLa SDK front-end object. >
class SLSourceForm {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 10194;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-05";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }
  static final int SLEELA     = 1;
  static final int SLDOCUMENT = 2;
  static final int SLSCRIPT   = 3;

  int form;
  < canonical extension, including the dot >
  String extension;
  < true when the form runs strictly top-down >
  boolean ordered;

  void configure(int whichForm) {
    form = whichForm;
    if (whichForm == SLEELA) { extension = ".sleela"; ordered = false; }
    else if (whichForm == SLDOCUMENT) { extension = ".sldocument"; ordered = true; }
    else if (whichForm == SLSCRIPT) { extension = ".sleela-script"; ordered = true; }
    else { extension = ""; ordered = false; }
  }

  < Infer the source form from a file name's extension. Returns 0 (unknown) when >
  < the extension is not a recognised SLeeLa source form. >
  int fromExtension(String fileName) {
    if (endsWith(fileName, ".sldocument")) { configure(SLDOCUMENT); return SLDOCUMENT; }
    if (endsWith(fileName, ".sleela-script")) { configure(SLSCRIPT); return SLSCRIPT; }
    if (endsWith(fileName, ".sleela")) { configure(SLEELA); return SLEELA; }
    form = 0; extension = ""; ordered = false;
    return 0;
  }

  int value() { return form; }
  String ext() { return extension; }
  boolean isOrdered() { return ordered; }
  boolean isDocument() { return form == SLDOCUMENT; }
  boolean isProgram() { return form == SLEELA; }

  < Small helper: does `s` end with `suffix`? (The .sldocument check runs before >
  < the .sleela check so the longer extension is matched first.) >
  boolean endsWith(String s, String suffix) {
    if (s == null || suffix == null) { return false; }
    int sl = s.length();
    int fl = suffix.length();
    if (fl > sl) { return false; }
    return s.substring(sl - fl, sl) == suffix;
  }
}