Skip to content
This repository has been archived by the owner on Apr 13, 2019. It is now read-only.

schema language

Chris Dessonville edited this page Jul 20, 2017 · 29 revisions

This is a draft page filled as we go with the language implementation. The ultimate source of truth for the syntax is schema.bnf.

Overview

Epigraph schema files have an .epigraph extension and consist of a namespace declaration followed by imports followed by type and resource declarations.

Namespace declaration

Namespace declaration is mandatory and consists of a namespace keyword followed by a fully-qualified namespace. Fully-qualified namespace is a list of dot-separated namespace names forming a hierarchy, similar to Java packages. Namespace names must be lower-cased.

Namespaces are used to organize types and resources into logical groups. They may also be translated by the code generators into appropriate language constructs such as packages.

Imports

There are two kinds of imports: namespace imports and single type imports.

Single type import makes one single type from another package available:

import foo.bar.Baz

record R {
  myField: Baz
}

Importing types with the same short name from different namespaces is not allowed:

import foo.bar.Baz
import qux.Baz // clash!

Namespace import brings given namespace into the scope, so that namespace prefix can be omitted:

import foo.bar

record R {
  myField: bar.Baz
}

Importing namespaces with the same last segment is not allowed:

import foo.bar
import qux.bar // clash!

Standard imports

The following imports are always implicitly present:

import epigraph.String
import epigraph.Integer
import epigraph.Long
import epigraph.Double
import epigraph.Boolean

Resolution sequence

Type references are resolved in the following order:

  1. Using explicit imports
  2. Using implicit (standard) imports
  3. Types from the same (current) namespace

See References implementation for more technical details.

Inheritance

Type A inherits type B if they are of the same kind and one of the following is true:

  • A extends B
  • B supplements A
  • A is a member of a entity V and B supplements V
  • A inherits T, and T inherits B (transitivity)

Abstract and final type members

Clone this wiki locally