lutaml-lml 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lutaml/lml/cli.rb +12 -3
- data/lib/lutaml/lml/data_processor/attribute_processing.rb +49 -9
- data/lib/lutaml/lml/data_processor/instance_processing.rb +5 -0
- data/lib/lutaml/lml/data_processor/value_declaration_processing.rb +62 -0
- data/lib/lutaml/lml/data_processor.rb +3 -0
- data/lib/lutaml/lml/document_builder.rb +235 -9
- data/lib/lutaml/lml/grammar/lml.artifact.json +6473 -2425
- data/lib/lutaml/lml/grammar/lml.parg +82 -19
- data/lib/lutaml/lml/model_compiler.rb +392 -39
- data/lib/lutaml/lml/models/data_type.rb +3 -0
- data/lib/lutaml/lml/models/derived_field.rb +14 -0
- data/lib/lutaml/lml/models/document.rb +2 -0
- data/lib/lutaml/lml/models/enum.rb +3 -0
- data/lib/lutaml/lml/models/instance.rb +2 -0
- data/lib/lutaml/lml/models/instance_collection.rb +1 -0
- data/lib/lutaml/lml/models/mapping.rb +15 -0
- data/lib/lutaml/lml/models/mapping_rule.rb +16 -0
- data/lib/lutaml/lml/models/member_field.rb +12 -0
- data/lib/lutaml/lml/models/namespace.rb +14 -0
- data/lib/lutaml/lml/models/package.rb +1 -0
- data/lib/lutaml/lml/models/serialization_mapping.rb +17 -0
- data/lib/lutaml/lml/models/string_format.rb +16 -0
- data/lib/lutaml/lml/models/top_element_attribute.rb +4 -0
- data/lib/lutaml/lml/models/uml_class.rb +4 -0
- data/lib/lutaml/lml/preprocessor.rb +82 -6
- data/lib/lutaml/lml/validator.rb +276 -0
- data/lib/lutaml/lml/version.rb +1 -1
- data/lib/lutaml/lml.rb +8 -0
- metadata +11 -2
|
@@ -38,7 +38,7 @@ grammar Lml version "1.0.0" {
|
|
|
38
38
|
boolean = ( "true" / "false" ) as boolean
|
|
39
39
|
number = ( 1*%x30-39 "." 1*%x30-39 ) as float / ( 1*%x30-39 ) as number
|
|
40
40
|
variable = quoted_string / 1*word
|
|
41
|
-
reference = "reference:(" ( variable *( "." variable ) ) as reference ")"
|
|
41
|
+
reference = ( "reference:(" / "ref:(" ) ( variable *( "." variable ) ) as reference ")"
|
|
42
42
|
range = ( variable as start ".." variable as end ) as range
|
|
43
43
|
namespaced_identifier = variable *( "::" variable )
|
|
44
44
|
comment_definition = [ ws ] ( "**" / "#" ) ( *( !newline any_char ) ) as comments
|
|
@@ -49,8 +49,8 @@ grammar Lml version "1.0.0" {
|
|
|
49
49
|
cardinality_body_definition = cardchar as min [ ".." [ cardchar as max ] ]
|
|
50
50
|
cardinality = "[" cardinality_body_definition as cardinality "]"
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
key_value_pair = variable as key ws [ "=" ] [ ws ]
|
|
52
|
+
data_value = boolean / reference / range / number / quoted_string
|
|
53
|
+
key_value_pair = variable as key ws [ "=" ] [ ws ] data_value as value
|
|
54
54
|
key_value_map = "{" [ whitespace ] ( *( key_value_pair whitespace ) ) as key_value_map "}"
|
|
55
55
|
kw_visibility_modifier = "+" / "-" / "#" / "~"
|
|
56
56
|
|
|
@@ -69,8 +69,11 @@ grammar Lml version "1.0.0" {
|
|
|
69
69
|
|
|
70
70
|
keyword_type_argument = "type" [ ws ] ( 1*nonspace ) as type [ whitespace ]
|
|
71
71
|
keyword_cardinality_argument = "cardinality" [ ws ] cardinality_body_definition as cardinality [ whitespace ]
|
|
72
|
-
keyword_any_argument = [ ws ] ( 1*nonspace ) as name ws [ "=" ] [ ws ] attribute_value as value [ whitespace ]
|
|
73
|
-
|
|
72
|
+
keyword_any_argument = [ ws ] ( 1*nonspace ) as name ws [ "=" / ":" ] [ ws ] attribute_value as value [ whitespace ]
|
|
73
|
+
keyword_values_argument = "values" ws ( ( value_set_body ) as value_set / ( variable ) as value_set_ref ) [ whitespace ]
|
|
74
|
+
keyword_pattern_argument = ( "pattern" ws "/" ( *( ( "\\" any_char ) / ( !"/" any_char ) ) ) as pattern "/" [ whitespace ] )
|
|
75
|
+
value_set_body = "{" [ whitespace ] ( *( ( ( data_value / variable ) as item ) [ "," ] [ whitespace ] ) ) as items "}"
|
|
76
|
+
keyword_attribute_options = *( keyword_type_argument / keyword_cardinality_argument / keyword_values_argument / keyword_pattern_argument / ( keyword_any_argument ) as properties )
|
|
74
77
|
keyword_attribute_body = "{" [ whitespace ] keyword_attribute_options [ whitespace ] "}"
|
|
75
78
|
keyword_attribute_definition = ( "attribute" ws attribute_name [ ws ] keyword_attribute_body ) as attributes
|
|
76
79
|
|
|
@@ -89,7 +92,43 @@ grammar Lml version "1.0.0" {
|
|
|
89
92
|
|
|
90
93
|
# ---- Definitions ----
|
|
91
94
|
class_modifier = [ ( [ whitespace ] ( "abstract" / "interface" ) ) as modifier ws ]
|
|
92
|
-
|
|
95
|
+
# ---- Namespaces (RS 3010 extension: lutaml-model XmlNamespace) ----
|
|
96
|
+
namespace_uri_line = ( [ ws ] "uri" ws ( quoted_string / ( 1*word ) ) as uri [ whitespace ] )
|
|
97
|
+
namespace_prefix_line = ( [ ws ] "prefix" ws ( quoted_string / ( 1*word ) ) as prefix [ whitespace ] )
|
|
98
|
+
namespace_body = "{" [ whitespace ] ( *( namespace_uri_line / namespace_prefix_line ) ) as members "}"
|
|
99
|
+
namespace_inline = ( ws ( quoted_string ) as uri [ ws "prefix" ws ( quoted_string / ( 1*word ) ) as prefix ] )
|
|
100
|
+
namespace_definition = ( [ whitespace ] "namespace" ws ( 1*word ) as name [ ws ] ( namespace_body / namespace_inline ) [ whitespace ] ) as namespaces
|
|
101
|
+
|
|
102
|
+
# ---- Serialization mappings (RS 3010 extension: sibling-linked) ----
|
|
103
|
+
serialization_body = "{" [ whitespace ] ( *( serialization_line ) ) as rules "}"
|
|
104
|
+
serialization_line = ( mapping_element_name_line / mapping_element_line / mapping_attribute_line / mapping_content_line / mapping_namespace_line / mapping_mixed_line / legacy_map_line / mapping_map_line / mapping_map_key_line / mapping_map_value_line ) [ whitespace ]
|
|
105
|
+
legacy_map_line = ( [ ws ] "map" ws dq_string as wire "," ws "to:" ws ( quoted_string / ( 1*word ) ) as to [ whitespace ] ) as legacy_map
|
|
106
|
+
mapping_element_name_line = ( [ ws ] "element" ws dq_string as element_name [ whitespace ] ) as element_name
|
|
107
|
+
mapping_element_line = ( [ ws ] "map_element" ws ( element_args ) ) as map_element
|
|
108
|
+
element_args = ( dq_string as wire [ ws ( 1*word ) as field ] / ( 1*word ) as field )
|
|
109
|
+
mapping_attribute_line = ( [ ws ] "map_attribute" ws ( attribute_args ) ) as map_attribute
|
|
110
|
+
attribute_args = ( dq_string as wire [ ws ( 1*word ) as field ] / ( 1*word ) as field )
|
|
111
|
+
mapping_content_line = ( [ ws ] "map_content" ws ( 1*word ) as field ) as map_content
|
|
112
|
+
mapping_namespace_line = ( [ ws ] "namespace" ws ( 1*word ) as namespace_ref ) as map_namespace
|
|
113
|
+
mapping_mixed_line = ( [ ws ] "mixed_content" ) as mixed_content
|
|
114
|
+
mapping_map_line = ( [ ws ] "map" ws map_args ) as map
|
|
115
|
+
map_args = ( dq_string as wire ws ( 1*word ) as field / dq_string as wire / ( 1*word ) as field )
|
|
116
|
+
mapping_map_key_line = ( [ ws ] "map_key" ws "to_instance" ws ( 1*word ) as field ) as map_key
|
|
117
|
+
mapping_map_value_line = ( [ ws ] "map_value" ws ( "to_instance" / "as_attribute" ) as mode ws ( 1*word ) as field ) as map_value
|
|
118
|
+
mapping_definition = ( [ whitespace ] "mapping" ws ( 1*word ) as format ws ( 1*word ) as target [ ws ] serialization_body [ whitespace ] ) as serialization_mappings
|
|
119
|
+
|
|
120
|
+
# ---- Mapping blocks (lutaml-model wire names) ----
|
|
121
|
+
map_name = ( quoted_string / 1*( word / "-" / "." ) )
|
|
122
|
+
map_line = [ ws ] "map" ws ( map_name ) as wire "," ws "to:" ws ( map_name ) as to [ whitespace ]
|
|
123
|
+
mapping_body = [ ws ] "{" [ whitespace ] ( *( map_line ) ) as maps "}"
|
|
124
|
+
class_mapping_section = ( [ whitespace ] "mapping" ws ( 1*word ) as format [ ws ] serialization_body [ whitespace ] ) as serialization_mappings
|
|
125
|
+
|
|
126
|
+
derive_definition = ( [ whitespace ] "derive" ws attribute_name [ ws ] ":" [ ws ] [ quotes ] ( 1*typechar ) as type [ quotes ] ) as derived_field [ whitespace ]
|
|
127
|
+
string_format_item = ( [ ws ] ( "artifact" / "root" ) as key ws ( quoted_string / 1*nonspace ) as value [ whitespace ] )
|
|
128
|
+
string_format_body = "{" [ whitespace ] ( *( string_format_item ) ) as items [ whitespace ] "}"
|
|
129
|
+
string_format_definition = ( [ whitespace ] "string_format" ws ( variable ) as format [ ws ] string_format_body ) as string_format
|
|
130
|
+
|
|
131
|
+
class_inner_definitions = definition_body / definition_line / class_mapping_section / derive_definition / string_format_definition / attribute_comma_definition / ( !( "attribute" ws ) attribute_definition ) / keyword_attribute_definition / comment_definition / comment_multiline_definition
|
|
93
132
|
class_inner_definition = class_inner_definitions [ whitespace ]
|
|
94
133
|
class_body = [ ws ] "{" [ whitespace ] ( *( class_inner_definition ) ) as members "}"
|
|
95
134
|
parent_class = [ ws ] "<" [ ws ] ( class_name_chars ) as parent_class
|
|
@@ -98,8 +137,26 @@ grammar Lml version "1.0.0" {
|
|
|
98
137
|
# Balanced-brace definition text: nested "{...}" and "\"-escapes allowed
|
|
99
138
|
definition_content = *( ( "\\" any_char ) / ( "{" definition_content "}" ) / ( !"}" any_char ) )
|
|
100
139
|
definition_body = [ ws ] "definition" [ whitespace ] "{" ( definition_content ) as definition "}"
|
|
101
|
-
|
|
102
|
-
|
|
140
|
+
definition_line = ( [ ws ] "definition" ws ( dq_string / sq_string ) ) as definition [ whitespace ]
|
|
141
|
+
|
|
142
|
+
member_field_line = [ ws ] attribute_name [ ws ] ( 1*nonspace ) as member_field_type [ whitespace ]
|
|
143
|
+
member_fields_definition = ( [ whitespace ] "member_fields" [ whitespace ] "{" [ whitespace ] ( *( member_field_line ) ) as member_fields [ whitespace ] "}" ) as member_fields_decl
|
|
144
|
+
attribute_comma_definition = ( [ whitespace ] "attribute" ws attribute_name "," [ ws ] ( 1*typechar ) as type [ ws ] [ "{" [ whitespace ] keyword_attribute_options [ whitespace ] "}" ] [ whitespace ] ) as attributes
|
|
145
|
+
enum_member_with_payload = ( [ whitespace ] attribute_name [ ws ] ( class_body / keyword_attribute_body ) ) as attributes
|
|
146
|
+
|
|
147
|
+
# ---- Canonical value construct (RS 3001 par. Value / par. Enums) ----
|
|
148
|
+
# `value <name> { block }` is the canonical enum member; the bare
|
|
149
|
+
# identifier member is its documented shortcut. from_table expands to
|
|
150
|
+
# value members at compile time.
|
|
151
|
+
value_name = quoted_string / map_name
|
|
152
|
+
value_inner_definition = ( definition_body / definition_line / instance / attribute_line / comment_definition / comment_multiline_definition ) [ whitespace ]
|
|
153
|
+
value_body = "{" [ whitespace ] ( *( value_inner_definition ) ) as members "}"
|
|
154
|
+
value_definition = ( [ whitespace ] "value" ws ( value_name ) as value_name [ ws ] [ value_body ] [ whitespace ] ) as value_decl
|
|
155
|
+
|
|
156
|
+
from_table_definition = ( [ whitespace ] "from_table" [ ws ] ( map_name ) as from_table_name [ ws ] [ "{" [ whitespace ] *( "artifact" [ ws ] ( map_name ) as artifact_table [ whitespace ] ) "}" ] [ whitespace ] ) as from_table_decl
|
|
157
|
+
|
|
158
|
+
enum_values_shorthand = ( [ whitespace ] "values" ws value_set_body [ whitespace ] ) as value_set_decl
|
|
159
|
+
enum_inner_definitions = definition_body / definition_line / member_fields_definition / from_table_definition / enum_values_shorthand / value_definition / enum_member_with_payload / attribute_comma_definition / attribute_definition / comment_definition / comment_multiline_definition
|
|
103
160
|
enum_inner_definition = enum_inner_definitions [ whitespace ]
|
|
104
161
|
enum_body = [ ws ] "{" [ whitespace ] ( *( enum_inner_definition ) ) as members "}"
|
|
105
162
|
enum_definition = [ whitespace ] "enum" ws [ quotes ] class_name as name [ quotes ] [ attribute_stereotype ] [ enum_body ]
|
|
@@ -107,12 +164,14 @@ grammar Lml version "1.0.0" {
|
|
|
107
164
|
data_type_definition = [ whitespace ] "data_type" ws [ quotes ] class_name as name [ quotes ] [ attribute_stereotype ] [ data_type_body ]
|
|
108
165
|
primitive_definition = [ whitespace ] "primitive" ws [ quotes ] class_name as name [ quotes ]
|
|
109
166
|
|
|
110
|
-
|
|
167
|
+
package_body = [ ws ] "{" [ whitespace ] ( *( diagram_inner_definition ) ) as members "}"
|
|
168
|
+
package_definition = ( [ whitespace ] "package" ws class_name as name [ ws ] package_body [ whitespace ] ) as packages
|
|
169
|
+
diagram_inner_definitions = namespace_definition / mapping_definition / package_definition / title_definition / caption_definition / fontname_definition / ( class_definition ) as classes / ( enum_definition ) as enums / ( primitive_definition ) as primitives / ( data_type_definition ) as data_types / ( association_definition ) as associations / comment_definition / comment_multiline_definition
|
|
111
170
|
diagram_inner_definition = diagram_inner_definitions [ whitespace ]
|
|
112
171
|
diagram_body = [ ws ] "{" [ whitespace ] ( *( diagram_inner_definition ) ) as members "}"
|
|
113
172
|
diagram_definition = [ whitespace ] "diagram" [ ws ] class_name as name diagram_body [ whitespace ]
|
|
114
173
|
diagram_definitions = diagram_definition [ whitespace ]
|
|
115
|
-
model_definitions = ( *( diagram_inner_definition ) ) as members
|
|
174
|
+
model_definitions = ( 1*( diagram_inner_definition ) ) as members
|
|
116
175
|
|
|
117
176
|
view_only_definitions = ( view_import ) as view_imports / show_directive / hide_directive
|
|
118
177
|
view_inner_definitions = view_only_definitions / diagram_inner_definitions
|
|
@@ -141,18 +200,20 @@ grammar Lml version "1.0.0" {
|
|
|
141
200
|
require_block = ( *( require_stmt [ whitespace ] ) ) as requires
|
|
142
201
|
|
|
143
202
|
# ---- Instances ----
|
|
144
|
-
instance = keyword_instance / class_instance
|
|
145
|
-
|
|
203
|
+
instance = instance_named / keyword_instance / class_instance
|
|
204
|
+
instance_named = ( [ whitespace ] "instance" ws quoted_string as name [ ws ] [ ( namespaced_identifier ) as instance_type ] [ ws ] "{" [ whitespace ] ( ( [ ws ] instance ) / attributes ) "}" [ whitespace ] ) as instance
|
|
205
|
+
isa_definition = [ whitespace ] "isa" ws ( namespaced_identifier ) as isa [ whitespace ]
|
|
206
|
+
keyword_instance = ( [ whitespace ] "instance" [ ws ( namespaced_identifier ) as instance_type ] [ ws ] "{" [ whitespace ] [ isa_definition ] ( ( [ ws ] instance ) / attributes ) "}" ) as instance [ whitespace ]
|
|
146
207
|
class_instance = ( variable as instance_type [ whitespace ] quoted_string as name [ whitespace ] [ [ whitespace ] "extends" [ whitespace ] quoted_string as parent [ whitespace ] ] "{" [ whitespace ] [ lml_instance_body ] "}" ) as instance [ whitespace ]
|
|
147
208
|
lml_instance_body = lml_instance_members [ whitespace ]
|
|
148
209
|
instance_template = [ whitespace ] "template" [ whitespace ] "{" [ whitespace ] attributes [ whitespace ] "}"
|
|
149
210
|
lml_instance_members = ( instance_template ) as template / attributes
|
|
150
|
-
models = [ whitespace ] "models" [ whitespace ] variable as name [ whitespace ] "{" ( *( model_body ) ) as members "}" [ whitespace ]
|
|
151
|
-
model_body =
|
|
211
|
+
models = [ whitespace ] "models" [ whitespace ] variable as name [ whitespace ] "{" ( *( ( ( string_format_definition ) as default_string_formats ) / model_body ) ) as members "}" [ whitespace ]
|
|
212
|
+
model_body = diagram_inner_definition
|
|
152
213
|
|
|
153
214
|
# ---- Data structures ----
|
|
154
|
-
attribute_value = instance / list / key_value_map /
|
|
155
|
-
list_item = instance /
|
|
215
|
+
attribute_value = instance / list / key_value_map / data_value / 1*( !%x0A any_char )
|
|
216
|
+
list_item = instance / data_value
|
|
156
217
|
list = "[" [ whitespace ] ( *( list_item [ ws ] [ "," ] [ whitespace ] ) ) as list [ whitespace ] "]"
|
|
157
218
|
collection = [ whitespace ] "collection" ws quoted_string as name [ ws ] "{" [ whitespace ] [ includes ] [ whitespace ] [ validation ] [ whitespace ] "}" [ whitespace ]
|
|
158
219
|
includes = [ whitespace ] "includes" [ ws ] ( list ) as includes
|
|
@@ -160,14 +221,16 @@ grammar Lml version "1.0.0" {
|
|
|
160
221
|
condition = [ whitespace ] "condition" ws quoted_string as condition [ whitespace ]
|
|
161
222
|
import = [ whitespace ] "import" [ ws ] "{" [ whitespace ] ( *( import_definition ) ) as imports "}" [ whitespace ]
|
|
162
223
|
import_definition = ( 1*nonspace ) as format_type [ ws ] quoted_string as file [ whitespace ] "{" [ whitespace ] attributes [ whitespace ] "}" [ whitespace ]
|
|
163
|
-
instances = [ whitespace ] "instances" [ whitespace ] "{" [ whitespace ] [ instances_body ] "}" [ whitespace ]
|
|
224
|
+
instances = [ whitespace ] "instances" [ ws ] [ ( quoted_string / variable ) as name ] [ whitespace ] "{" [ whitespace ] [ instances_body ] "}" [ whitespace ]
|
|
164
225
|
instances_body = ( *( instances_member [ whitespace ] ) ) as instances
|
|
165
226
|
instances_member = import / ( collection ) as collections / export / instance
|
|
166
227
|
export = [ whitespace ] "export" [ whitespace ] "{" [ whitespace ] ( *( export_format [ whitespace ] ) ) as exports "}" [ whitespace ]
|
|
167
228
|
export_format = [ whitespace ] "format" ws variable as format_type [ whitespace ] "{" [ whitespace ] attributes "}" [ whitespace ]
|
|
168
229
|
|
|
169
|
-
# ---- Root (
|
|
170
|
-
diagram = [ require_block ] (
|
|
230
|
+
# ---- Root (RS 3001: a document interleaves declarations) ----
|
|
231
|
+
diagram = [ require_block ] ( *( top_level_definition ) ) as members
|
|
232
|
+
|
|
233
|
+
top_level_definition = ( models / diagram_definitions / view_definitions / instances / instance / model_definitions ) [ whitespace ]
|
|
171
234
|
}
|
|
172
235
|
|
|
173
236
|
entry diagram: diagram
|