Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop LutaML modeling language to handle model and serialization definitions (was: LutaML-UML language) #174

Open
HassanAkbar opened this issue Nov 19, 2024 · 1 comment
Assignees

Comments

@HassanAkbar
Copy link
Member

HassanAkbar commented Nov 19, 2024

What is LutaML-UML

LutaML-UML is an ASCII syntax language for defining UML models:

It is a block-based, context-aware syntax with explicit delimitation.

Currently, it provides the following primitives:

  • diagram {diagram-name} {...block...}
  • class
  • association
  • enum
  • definition
  • package
  • abstract
  • comments: //
  • attribute value assignment {attribute-name-path} = ...
  • attribute visibility {visibility symbol}
  • instance

Approach

Our goal here is to upgrade this language to support all the features we have in lutaml-model, and just called it LutaML ("Luta Modeling Language").

There are a few levels we need to support:

  1. Data class definition level. i.e. lutaml-model
  2. Data instance definition level. i.e. as a replacement for Excel.

Basically, the way to approach this language is as follows.

The language supports only 4 things:

  1. Command syntax: {command} [args*]
  2. Block syntax: {command} [args*] {...block...}
  3. Primitives: String, etc.
  4. Out-of-band things like tail comments or multi-line comments

All the other fancy things can be defined as shorthand commands as alternative syntax to the full command.

Data class definition

Something like this:

class Computer {
  // Required single attribute (cardinality exactly 1)
  attribute id[1] : string {
    description "Unique identifier for computer"
  }

  // Optional single attribute (cardinality 0 or 1)
  attribute description[0..1] : string

  // Required collection (1 or more)
  attribute memory : Memory[1..*] {
    description "RAM modules installed"
    constraint valid_sizes {
      condition "::self->forAll(m | m.size > 0)"
    }
  }

  // Required vendor with enumerated values
  attribute vendor[1] : string {
    values {
      "Dell"
      "HP"
      "Lenovo"
    }
  }

  // CPU with nested required attributes
  class CPU {
    attribute architecture[1] : string {
      values {
        "x86"
        "x86_64"
        "arm64"
        "armhf"
      }
    }
    
    attribute speed[1] : decimal {
      constraint {
        condition "value > 0"
      }
    }

    // Optional firmware info
    attribute firmware : Firmware[0..1] {
      class Firmware {
        attribute version[1] : string
        attribute hash[1] : string {
          constraint sha512_format {
            condition "value matches /^[0-9a-fA-F]{128}$/"
          }
        }
      }
    }
  }
}

Data instance definition

Collection:

instances {
  // Named collection of instances
  collection "test_suite_1" {
    includes [
      "laptop_123",
      "desktop_1",
      "desktop_2"
    ]
    
    // Collection-level validation
    validation {
      condition "count >= 3"
      condition "all? { |i| i.components.count > 0 }"
    }
  }
}

Instance inheritance:

instances {
  // Base instance template
  Product "base_computer" {
    template {
      components = [
        Component "base_cpu" {
          type = "electronic"
          quantity = 1
        }
      ]
    }
  }

  // Instance extending template
  Product "gaming_pc" extends "base_computer" {
    name = "Gaming PC"
    // Add to inherited components
    components += [
      Component "gpu_1" {
        id = "GPU001"
        type = "electronic"
        quantity = 1
      }
    ]
  }
}

Instance import/export:

instances {
  // Import from external files
  import {
    xml "test_data/products.xml" {
      map_to Product
      where "//product"
    }
    
    csv "test_data/components.csv" {
      map_to Component
      columns {
        id = "component_id"
        type = "component_type"
        quantity = "count"
      }
    }
  }

  // Export specifications
  export {
    format xml {
      file "output/products.xml"
      indent true
      encoding "UTF-8"
    }
    
    format step {
      file "output/products.stp"
      reference_format "#%{id}"
    }
  }
}
@HassanAkbar HassanAkbar self-assigned this Nov 19, 2024
@ronaldtse ronaldtse changed the title Extend LUTAML UML language to handle lutaml-model modeling methods and serialization formats Develop LutaML modeling language to handle model and serialization definitions (was: LutaML-UML language) Jan 22, 2025
@ronaldtse
Copy link
Contributor

We will use the S-102 dataset and document to develop this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants