Class FrontMatter

java.lang.Object
org.ek9lang.compiler.common.FrontMatter

public final class FrontMatter extends Object
THE split of an example source into its <?- ... -?> JSON front matter and its EK9 body - the one reader of that format. Use it; never write another.

Three corpora share the format: the Q&A (qaExamples, read by org.ek9lang.assist.Ek9QaFileLoader and, for its declared output, by the execution tests), the site examples (siteExamples, read by org.ek9lang.site.SiteExampleSources) and the error catalogue's examples (errorExamples, read by ErrorExamples). The site-examples spec (D3) requires one reader for all of them, so a change to the format - a new delimiter rule, the //EOF trailer - happens here once. It lives in compiler-main (moved from compiler-services' assist package, lane L0e) because the error catalogue is read here, by ek9 -h <CODE> and -E3.

The front matter is an EK9 comment block, so the file still compiles; the body is everything after the closing marker, trimmed, with a trailing //EOF removed (the corpus convention for "the source ends here").

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The closing marker of the front matter.
    static final String
    The opening marker of the front matter.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    body(String text)
    The EK9 source after the front matter, trimmed and without a trailing //EOF; the whole text (likewise trimmed) when there is no front matter.
    static boolean
    has(String text)
    True when the text carries front matter.
    static String
    json(String text)
    The JSON between the markers, trimmed, or null when the text has no well-formed front matter.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • json

      public static String json(String text)
      The JSON between the markers, trimmed, or null when the text has no well-formed front matter.
    • body

      public static String body(String text)
      The EK9 source after the front matter, trimmed and without a trailing //EOF; the whole text (likewise trimmed) when there is no front matter.

      EK9 REQUIRES #!ek9 as a file's first line and the example files put it BEFORE the front matter, so the body restores it as its own first line (Steve, 2026-10-12: every whole-file example shows it, so code copied from a page compiles and a capture's line N is the Nth line shown). THE one place that used to drop it; a region (SourceRegions.extract(String, String)) still shows only its region.

    • has

      public static boolean has(String text)
      True when the text carries front matter.