the-sett/salix/2.0.0

NOTE: the latest version is 4.0.3

L3

Defines the level 3 language for data models that have been annotated with properties indicating that the model has particular features needed by particular code generators.

A level 3 language ensures the specific requirements for processing by a specific code generator are being met.

The L3 data modelling language.

type alias L3 pos =
{ properties : Properties
, declarations : Dict String (Declarable pos RefChecked)
}

The L3 model. This consists of an L2 model and a set of top-level properties that a code generator needs to know.

Defaulting of properties across the data model, and APIs to read properties.

type alias DefaultProperties =
{ top : ( PropSpecs, Properties )
, alias : ( PropSpecs, Properties )
, sum : ( PropSpecs, Properties )
, enum : ( PropSpecs, Properties )
, restricted : ( PropSpecs, Properties )
, fields : ( PropSpecs, Properties )
, unit : ( PropSpecs, Properties )
, basic : ( PropSpecs, Properties )
, named : ( PropSpecs, Properties )
, product : ( PropSpecs, Properties )
, emptyProduct : ( PropSpecs, Properties )
, container : ( PropSpecs, Properties )
, function : ( PropSpecs, Properties )
}

Allows the default properties on parts of the model to be defined.

type alias PropertiesAPI pos =
{ top : PropertyGet
, declarable : Declarable pos RefChecked -> PropertyGet
, field : Properties -> PropertyGet
, type_ : Type pos RefChecked -> PropertyGet
}

An API for supplying property readers for various parts of the data model.

type alias PropertyGet =
{ getStringProperty : String -> ResultME PropCheckError String
, getEnumProperty :
Enum String -> String -> ResultME PropCheckError String
, getQNameProperty :
String -> ResultME PropCheckError (List String)
, getBoolProperty : String -> ResultME PropCheckError Bool
, getOptionalStringProperty :
String -> ResultME PropCheckError (Maybe String)
, getOptionalEnumProperty :
Enum String -> String -> ResultME PropCheckError (Maybe String)
}

An API for reading properties of various expected kinds.

makePropertiesAPI : DefaultProperties -> L3 pos -> PropertiesAPI pos

Creates a properties API from a set of defaulted property specs, and an L3 model.

Standardized interface to an L3 processor.

type alias Processor pos =
{ name : String
, defaults : DefaultProperties
, check : L3 pos -> ResultME Error (L3 pos)
}

API for an L3 model processor.

type alias ProcessorImpl pos err =
{ name : String
, defaults : DefaultProperties
, check : L3 pos -> ResultME err (L3 pos)
, buildError : ErrorBuilder pos err
}

SPI for an L3 model processor. Use the builder to turn one of these into a Processor.

builder : (pos -> SourceLines) -> ProcessorImpl pos err -> Processor pos

Builds an L3 Processor API from an implementation. A function to turn source code positions into quoted lines of source code needs to be supplied.

Default error catalogue for property errors.

= CheckedPropertyMissing String PropSpec
| CheckedPropertyWrongKind String PropSpec

Once properties have been checked, then reading properties as per the property specification should always succeed, since those properties have been verified to be present and of the correct kind.

If reading a property fails, it is a coding error and should be reported as a bug. This error type enumerates the possible properties bugs.

errorBuilder : (pos -> SourceLines) -> PropCheckError -> Error

Convert prop check errors to standard errors.

errorCatalogue : Dict Int ErrorMessage

The error catalogue for this property checking.

The error message here are quite generic, and you likely want to re-write this error catalogue for specific modules in order to give better messages.