Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openmodelica/metamodelica.jl
https://github.com/openmodelica/metamodelica.jl
julia-package
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/openmodelica/metamodelica.jl
- Owner: OpenModelica
- License: other
- Created: 2019-06-07T18:42:20.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T14:49:56.000Z (11 months ago)
- Last Synced: 2024-06-11T17:54:59.879Z (7 months ago)
- Topics: julia-package
- Language: Julia
- Size: 249 KB
- Stars: 4
- Watchers: 5
- Forks: 5
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MetaModelica.jl [![License: OSMC-PL](https://img.shields.io/badge/license-OSMC--PL-lightgrey.svg)](OSMC-License.txt)
This package replicates the runtime of the programming language MetaModelica. It also exposes
other packages that are a part of this runtime such as ImmutableList.jlMetaModelica supports a powerfull but expensive mechanism for pattern matching called matchcontinue
This is provided by an extension of Rematch.jl# Style
This package follows [YASGuide](https://github.com/jrevels/YASGuide).
Adherence to the standard will be checked during CI.# Pattern Matching and Patterns:
* `_` matches anything
* `foo` matches anything, binds value to `foo`
* `foo(__)` wildcard match on all subfields of foo, binds value to `foo`
* `Foo(x,y,z)` matches structs of type `Foo` with fields matching `x,y,z`
* `Foo(x=y)` matches structs of type `Foo` with a field named `x` matching `y`
* `[x,y,z]` matches `AbstractArray`s with 3 entries matching `x,y,z`
* `(x,y,z)` matches `Tuple`s with 3 entries matching `x,y,z`
* `[x,y...,z]` matches `AbstractArray`s with at least 2 entries, where `x` matches the first entry, `z` matches the last entry and `y` matches the remaining entries.
* `(x,y...,z)` matches `Tuple`s with at least 2 entries, where `x` matches the first entry, `z` matches the last entry and `y` matches the remaining entries.
* `_::T` matches any subtype (`isa`) of T
* `x || y` matches values which match either `x` or `y` (only variables which exist in both branches will be bound)
* `x && y` matches values which match both `x` and `y`
* `x where condition` matches only if `condition` is true (`condition` may use any variables that occur earlier in the pattern eg `(x, y, z where x + y > z)`)
* Anything else is treated as a constant and tested for equality* Patterns can be nested arbitrarily.
* Pattern matching is also possible on the list implementation provided by ImmutableList.jl:
`H <| T matches the head to H and the tail to T for a given input list `
`_ <| T matches a wildcard head and the tail to T for a given input list `
`nil() or list() matches the empty list`* Repeated variables only match if they are equal:
eg `(x,x)` matches `(1,1)` but not `(1,2)`.# @shouldFail
`@shouldFail(arg)` Is a special construct of MetaModelica.
It succeeds if arg fails, where arg is a local match-equation/statement.
# Optional
An optional datatype
SOME(X), NONE(). Works in match statements