sql_mapping

sql-mirror grammar version 85

'formatting': group {
	'identifier wrapping': [ identifier-delimiter: ] group {
		'open': text
		'close': text
	}
	'data type mapping': [ data-types ] group {
		'key': [ key: ] text
		'text': [ text: ] text
		'number': [ number: ] text
		'state': [ state: ] text
	}
}
'tables': [ schema ] dictionary {
	'primary key': [ <-- ] group {
		'root key field': stategroup (
			'no' {
				'entity type path': component 'entity type path'
			}
			'yes' {
				'root key': [ (, ) ] text
			}
		)
		'key fields': dictionary { [ [ ]
			'has predecessor': stategroup = node-switch predecessor (
				| node = 'yes' { 'predecessor' = predecessor }
				| none = 'no'
			)
			'has successor': stategroup = node-switch successor (
				| node = 'yes' { 'successor' = successor }
				| none = 'no'
			)
			'has tail': [ ] ] stategroup (
				'no' { }
				'yes' {
					'entity type path': component 'entity type path'
				}
			)
		}
		'has key fields': stategroup = node-switch .'key fields' (
			| nodes = 'yes' {
				'first' = first
				'last' = last
			}
			| none  = 'no'
		)
	}
	'fields': [ {, } ] dictionary {
		'has successor': stategroup = node-switch successor (
			| node = 'yes' { 'successor' = successor }
			| none = 'no'
		)
		'type': [ : ] stategroup (
			'key' {
				'type': stategroup (
					'primary key' { [ primary-key ] }
					'foreign key' { [ foreign-key ] }
				)
			}
			'text' { [ text ] }
			'number' { [ number ] }
			'state' { [ state ]
				'values': [ (, ) ] dictionary { }
			}
		)
	}
	'has fields': stategroup = node-switch .'fields' (
		| nodes = 'yes' { 'first' = first }
		| none  = 'no'
	)
}
'root table': [ mapping root ] component 'optional table selection'
'mapping': component 'mapping definition'
'entity scoped node type path' {
	'has steps': stategroup (
		'no' { }
		'yes' {
			'type': stategroup (
				'group' {
					'group': [ + ] reference
				}
				'state' {
					'state group': [ ? ] reference
					'state': [ | ] reference
				}
			)
			'tail': component 'entity scoped node type path'
		}
	)
}
'entity type path' {
	'head': component 'entity scoped node type path'
	'collection': [ . ] reference
}
'table selection' {
	'table': [ --> table ] reference
}
'optional table selection' {
	'select table': stategroup (
		'yes' {
			'table': component 'table selection'
		}
		'no' { }
	)
}
'mapping definition' { [ (, ) ]
	'properties': dictionary {
		'include': stategroup (
			'no' { [ (ignore) ] }
			'yes' {
				'type': [ : ] stategroup (
					'text' { [ text ]
						'has constraint': stategroup (
							'no' {
								'field': [ --> ] reference
							}
							'yes' { [ (->) ]
								'field': [ --> ] reference
							}
						)
					}
					'number' { [ number ]
						'field': [ --> ] reference
					}
					'file' { [ file ]
						'token field': [ --> ] reference
						'extension field': [ . ] reference
					}
					'group' { [ group ]
						// 'optional table' component 'optional table selection'
						'mapping': component 'mapping definition'
					}
					'state group' { [ stategroup ]
						'state group to field mapping': stategroup (
							'no' { }
							'yes' { [ --> ]
								'field': reference // reference !&'table'.'fields'
							}
						)
						'states': [ (, ) ] dictionary { [ | ]
							'state to state value mapping': stategroup (
								'no' { }
								'yes' { [ --> ]
									'value': reference
								}
							)
							// 'optional table' component 'optional table selection'
							'mapping': component 'mapping definition'
						}
					}
					'collection' { [ collection ]
						'table': component 'table selection'
						'mapping': component 'mapping definition'
					}
				)
			}
		)
	}
}