Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@273 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
x97davka
committed
Apr 23, 1998
1 parent
4dc252d
commit 54048fb
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
(** | ||
** file: values.rml | ||
** | ||
** The modeul `Values' contains data structures for representing | ||
** constant Modelica values. These include integer, real, string and | ||
** boolean values, and also arrays of any dimensionality and type. | ||
** Multidimensional arrays are represented as arrays of arrays. | ||
** | ||
** FIXME: complex types? | ||
**) | ||
|
||
module Values : | ||
|
||
datatype Value = INTEGER of int | ||
| REAL of real | ||
| STRING of string | ||
| BOOL of bool | ||
| ARRAY of Value list | ||
|
||
relation val_string : Value => string | ||
relation print_val : Value => () | ||
|
||
end | ||
|
||
relation val_string : Value => string = | ||
|
||
rule int_string n => s | ||
----------------- | ||
val_string INTEGER(n) => s | ||
|
||
rule real_string x => s | ||
------------------ | ||
val_string REAL(x) => s | ||
|
||
axiom val_string STRING(s) => s | ||
|
||
axiom val_string BOOL(FALSE) => "FALSE" | ||
axiom val_string BOOL(TRUE) => "TRUE" | ||
|
||
rule val_list_string vs => s & | ||
string_append("[",s) => s' & | ||
string_append(s',"]") => s'' | ||
---------------------------- | ||
val_string ARRAY(vs) => s'' | ||
|
||
end | ||
|
||
relation val_list_string : Value list => string = | ||
|
||
rule val_string v => s | ||
----------------- | ||
val_list_string [v] => s | ||
|
||
rule val_string v => s & | ||
val_list_string vs => s' & | ||
string_append (s,",") => s'' & | ||
string_append (s'',s') =>s''' | ||
------------------------------ | ||
val_list_string v::vs => s''' | ||
|
||
end | ||
|
||
relation print_val : Value => () = | ||
|
||
rule val_string v => s & | ||
print s | ||
------- | ||
print_val v | ||
|
||
end | ||
|