tree-sitter-sdml
A tree-sitter grammar for the Simple Domain Modeling Language (SDML). For more information on the language, see the documentation.
Example
module Campaign base <https://advertising.amazon.com/api-model> is
import [dc skos xsd]
@skos:prefLabel = "Campaign sub-domain"@en
@skos:version = xsd:decimal(2)
datatype Name <- xsd:string is
@xsd:minLength = 5
@xsd:maxLength = 25
end
datatype CampaignId <- xsd:string is
@skos:prefLabel = [
"Campaign Identifier"@en
"Identified de campagne"@fr
]
end
structure Tag is
key -> xsd:NMTOKEN
value -> {0..} rdfs:langStrings
end
entity campaign is
identity id -> CampaignId
name -> Name is
@skos:definition = "the name of the campaign"@en
end
tag -> {0..} Tag
ref target -> {1..} Target
end
entity Target
end
Changes
Version: 0.1.40
- Feature: add the Unicode character
↦to the rule_has_typewhich works better for some typesetting. - Feature: add rule for
inequationalongsideequation.- Add new rule
inequationand make it a choice withinsimple_sentence. - Add new rules for inequality relations;
not_equal,less_than,less_than_or_equal,greater_than, andgreater_than_or_equal.
- Add new rule
- Refactor: restructure rule
boolean_sentenceinto a choice ofunary_boolean_sentenceandbinary_boolean_sentence.- Add rule
unary_boolean_sentencefor negation only. - Add rule
binary_boolean_sentencefor logical connectives. - Add rules for each logical connective keyword/operator symbols.
- Add rule
- Refactor: rename field
variable_bindingto ``bindingin rulequantieid_sentence`. - Refactor: use the same rule for empty set in value sequences.
- Refactor: rename rule
_function_type_expression_toto_function_type. - Refactor: add rules
_has_typeand_type_restrictionand allow both ascii and Unicode arrows.- Add rule
_has_typefor values->and→. - Add rule
_type_restrictionfor values<-and←.
- Add rule
- Fix: rules for new shared bindings had confusing names.
- Add rule
quantified_variable_binding. - Rename rule
quantifier_bindingtoquantifier_bound_names.
- Add rule
- Docs: add appendix with details of Unicode usage.
Version: 0.1.39
- Feature: allow multiple bindings at the head of quantified sentences.
- Feature: made progress on local scopes in highlighting.
- Rename rule
_constant_deftoconstant_def. - To-do: currently references are not picking up their definition formatting.
- Rename rule
- Refactor: rename rule
name_pathtofunction_composition. - Refactor: combine components of the two rules
quantified_sentenceandsequence_builder.- Add new shared rule
quantifier_binding(along with_bound_name_set) now used in both sentence and builder. - Add the ability to have more than one name in a binding.
- Add the ability for sequence builders to have more than one quantified binding.
- Change the field
expressioninto a field namedbodyof typeconstraint_sentence. - Remove rules
expressionandconjunctive_expression.
- Add new shared rule
- Style: change the order of choices in rule
predicate_valueto matchvalueand corresponding sequences.
Version: 0.1.38
- Feature: Update naming for iterators to make them consistent.
- Rename rule
iterator_targettoiterator_source. - Rename field
fromintype_iteratortosource. - Rename field
frominsequence_iteratortosource.
- Rename rule
Version: 0.1.37
- Feature: update rule
function_cardinality_expressionto allow sequence constraints.- Rename rule
any_typetowildcard. - Remove rule
any_cardinalityand replace withwildcard.
- Rename rule
- Feature: rename lists to sequences.
- Rename rule
list_of_predicate_valuestosequence_of_predicate_values. - Rename rule
list_of_valuestosequence_of_values.
- Rename rule
- Feature: make rule
property_roleprivate as_property_role. - Feature: allow sequence constraints on sequence values.
- Add rule
_sequence_value_constraints. - Add optional
_sequence_value_constraintsto rulesequence_of_predicate_values. - Add optional
_sequence_value_constraintsto rulesequence_of_values.
- Add rule
Version: 0.1.36
- Feature: alter the rule
sequence_comprehensionto be more flexible.- Rename rule
sequence_comprehensiontosequence_builder. - Rename rule
returned_valuetovariablesand re-write as a choice of: - Add rule
tuple_variableto return distinct variables. - Add rule
sequence_variableto return distinct variables as a sequence. - Add rule
mapping_variableto return two variables as a mapping.
- Rename rule
Version: 0.1.35
- Feature: alter the rule
_property_memberto allow property names to beidentifier_reference.- New interpretation, field
namein a member will be the name of a role. - Renamed keyword
in, notas. - Renamed field
roletopropertyand made it's typeidentifier_reference.
- New interpretation, field
Version: 0.1.34
- Feature: update property definitions to look more like members.
- Update rule
property_roleto be a choice of three new rules. - Add rule
identity_rolewhich is a subset ofidentity_member. - Add rule
role_by_valuewhich is a subset ofmember_by_value. - Add rule
role_by_referencewhich is a subset ofmember_by_reference.
- Update rule
Version: 0.1.33
- Feature: renamed quantifier binding targets to be more consistent.
- Rename rule
binding_targettoiterator_target. - Rename rule
binding_type_referencetotype_iteratorand field namefrom_typetofrom. - Rename rule
binding_seq_iteratortosequence_iteratorand field namefrom_sequencetofrom.
- Rename rule
- Feature: simplified the rule
environment_definitionand made naming more consistent.- Remove optional
signaturefield - Remove assignment operators
- Rename field name
rhstobodyand change to a choice offunction_defor_value_def. - Add rule
function_defto hold the signature and operators removed from the environment definition. - Rename rule
fn_parametertofunction_parameter. - Rename rule
_fn_typeto_function_type_expression_to. - Add rules
function_cardinality_expressionandany_cardinalityto capture cardinality or wildcard. - Add rule
function_type_referenceto allow wildcards.
- Remove optional
- Feature: update queries
highlights,locals, andtagsfor all changes above. - Docs: update BNF syntax and diagrams for all changes above.
Version: 0.1.32
- Feature: update environment definition sequence types to use the same syntax as member type and cardinality.
Version: 0.1.31
- Feature: update highlighting queries for constraints with support for locals.
- Feature: add a
locals.scmfile with scopes for formal constraints. - Feature: add
∅(empty set) as a synonym for[]in constraints. - Fix: update the mapping value test case to use domain/range field names.
Version: 0.1.30
- Feature (minor): added field names for the domain and range of mapping types and values.
Version: 0.1.29
- Fix: an apparent regression, the value for a constructor changed from
simple_valuetovalue. This changes it back.
Version: 0.1.28
- Feature: add a mapping type and corresponding value syntax.
Version: 0.1.27
- Feature: add ordering and uniqueness constraints into the cardinality expression. Used to constrain the sequence type of a member.
Version: 0.1.26
- Feature: applied same change as 0.1.25 but for property roles as well.
Version: 0.1.25
- Feature: changed grammar for reference members:
- The production
source_cardinalityhas been removed. - The production
member_inverse_namehas been added.
- The production
Version: 0.1.24
- Feature: constraint changes
- Add a language-tag to informal constraints.
- Add a wildcard type for the constraint language.
Version: 0.1.23
- Feature: add highlighting test for constraints, had to tweak a few things.
Version: 0.1.22
- Feature: clarify rules and associated meaning.
- Rename the grammar rule
type_definitiontodefinitionto address the fact that property definitions aren't types. - Rename the grammar rule
enum_varianttovalue_variantto align withtype_varianton unions.
- Rename the grammar rule
Version: 0.1.21
- Feature: add support for sequence builder support(set builder) syntax.
- Fix: highlighting/indent/fold updated for constraints.
- Style: a number of cosmetic changes to formal constraints.
Version: 0.1.19/0.1.20
- Fix: minor change to add a field name to the '..' range operator.
Version: 0.1.18
- Feature: add a constraint assertion construct. This allows for specific constraints to be documented for any model element.
- The grammar rule
annotationhas been renamedannotation_property - The grammar rule
constrainthas been added. - A new grammar rule named
annotationis defined as a choice ofannotation_propertyorconstraint. - This allows the use of the old rule to be subsumed by the new definition.
- The grammar rule
- Constraints can be written in informal unstructured fashion or an embedded formalism.
- The informal representation is simply a string.
- The formal representation is a syntax that maps to a subset of ISO/IEC 24707:2018 Common Logic.
- More documentation added on the RDF mapping and the domain modeling process.
module example is
import tag
structure Thing is
inner -> {0..} InnerThing is
;; informal
assert same_tags = "All inner tags contain a tag value \"This\"."
;; formal
assert same_tags_formal is
forall self ( not_empty(self) and contains(self.tags "This") )
end
end
end
structure InnerThing is
tags -> {0..} tag:Tag
end
end
Version: 0.1.17
- Fixed highlighting for properties.
Version: 0.1.16
- Adjusted property grammar.
- Started on property documentation.
module ddict is
import account
property accountId is
@skos:prefLabel = "accountId"@en
@skos:altLabel = "account_id"@en
identifier -> {1} account:AccountId is
@skos:definition = "Used as an identifier for account-scoped things"@en
end
reference ref {1} -> {1} account:AccountId
end
structure Account is
accountId as identifier
name -> string
end
end
Version: 0.1.15
- Added new structure to the grammar to allow data-dictionary style reusable property definitions.
module ddict is
import account
property accountId -> account:AccountId is
@skos:prefLabel = "accountId"@en
@skos:altLabel = "account_id"@en
identifier is
@skos:definition = "Used as ..."@en
end
default = {1..1}
end
structure Account is
accountId as default
name -> string
end
end
Version: 0.1.14
- Added new rule named
builtin_simple_type(choice ofstring,double,decimal,integer,boolean, andiri):- replaced
identifier_referencewith new ruledata_type_basefordata_type_def, - added to the
type_referencechoice used for the membertargetfield.
- replaced
Allows both:
module example is
datatype mystring <- string
structure Person is
name -> string
age -> integer
end
end
Where the keywords string and integer will be expanded into the qualified identifiers sdml:string and
sdml:integer respectively.
Version: 0.1.13
- Added explicit
basegrammar for module rather than usingxml:baseas an attribute. - Expanded grammar for
Identifierto allow decimal digits in any position after the first. - Clarified the grammar for
TypeVariant.
Introduces:
module example base <https://example.org/v/example> is
end
Which replaces the annotation form:
module example is
import xml
@xml:base = <https://example.org/v/example>
end
Version: 0.1.12
- Fixed highlight issue for annotations with
IdentifierReferencevalues - Added field for
TypeVariantname
Version: 0.1.11
- Added a rename to optional value to
TypeVariant - Fixed
annotationandlanguage_taggrammar rule conflict
Introduces:
module example is
union Example is
Variant1
Variant1 as Alternative
end
end
This allows the use of the same type as a variant more than once if the new identifier is unique within the same union.
Version: 0.1.10
- Cleaned up queries.
Version: 0.1.9
- Simplified the disjoint
UnionDeftype.
Version: 0.1.8
- Added a disjoint
UnionDeftype.
Version: 0.1.7
- Made field name
sourceCardinalityintosource_cardinality. - Made field name
targetCardinalityintotarget_cardinality. - Added versioning annotations
Version: 0.1.6
- Made
_simple_valueintosimple_valuenamed rule. - Made
_type_referenceintotype_referencenamed rule.