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

schema language

Konstantin Sobolev edited this page May 3, 2016 · 29 revisions

This is a draft page filled as we go with the language implementation

#Imports There are three kinds of imports: star imports, namespace imports and single type imports.

Star imports bring all types from a given namespace into the scope, but not from any nested namespaces. For example:

import foo.bar.*

record R {
  myField: Baz // can be foo.bar.Baz
}

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 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!

Implementation details

Resolution algorithm works by building a set of namespace prefixes to search plus a suffix to look for. For example if prefixes are p1.p2 and p3.p4 and suffix is p5.P then p1.p2.p5.P and p3.p4.p5.P fully-qualified names will be the final candidates.

Internally there are two kinds of imports: star imports and prefix imports. Both namespace and single type imports are treated as prefix imports.

Resolution of reference R depends on if it's a sequence of fragments n1.n2...T or just one fragment T.

If R is just a single fragment like Baz, then namespace prefix set consists of:

  • current file's namespace
  • all star imports
  • all imports such that their last segment is R, with last segment removed
  • standard namespaces: epigraph.types.* and epigraph.schema.* Suffix is just R.

If R contains multiple fragments starting with n1, then prefix set is a union of all prefix imports such that their last segment is n1, with last segment removed. Search suffix is again R. // TODO this time built-in namespaces are not included

Clone this wiki locally