Skip to content

Commit

Permalink
New file
Browse files Browse the repository at this point in the history
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.
71 changes: 71 additions & 0 deletions modeq/values.rml
@@ -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

0 comments on commit 54048fb

Please sign in to comment.