Skip to content

Commit

Permalink
Array handling is probably broken in this version. Should be fixed in…
Browse files Browse the repository at this point in the history
… next version.

1999-03-19
Multiple return values from functions.

	1999-03-23 Constant propagation in functions.
	With only one output from functions the ouput varaible was
	is consant only if all input parameters are constant.
	With multiple return arguments from functions then some
	output parameters may be constant if some input parameters
	are. This should be checked in the future.

	!! Check inst.rml::inst_eq_equation understand the rule
	evaluation and extend it to multiple return values.

	1999-03-26
	Change of plans. Add  an tuple type instead. This type is
	not in the 1.1 spec. but will probably be there in the future.
	1999-03-27
	constant checking of the tuple�'s arguments is not done at
	the moment. See PROP in staticexp.rml.
	See staticexp.rml
		Write a test and make sure that it passes.
	1999-03-29
	About updating rml code. For example uptadeting
	Properties with Const. The old structure bool still works, just
	code for the extre bool list?
	1999-04-06
Tuples works. But it is not restricted to just functions,
like the modelica 1.1 specification. A bug is that Real x,y;
(x,y)=(1,2); Does not work but (x,y)=(1.0,3.0) works.


1999-04-06
	Type convertion from int to real does not work correctly
	with tuples. Real x,y;  (x,y) = (1,2); does not work.


1999-03-19
Array size allowed in component claus.
	(modelica_1_1_Type9.mo) Write a tests and make sure that
it passes. ok
done 1999-03-23


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@480 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x98petro committed Apr 19, 1999
1 parent 55298a3 commit a1071c8
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 34 deletions.
6 changes: 4 additions & 2 deletions modeq/ast/Makefile
Expand Up @@ -10,7 +10,7 @@
# ANTLR-defined token types
#

RMLINCLUDE = /home/pelab/pub/pkg/rml/current/sol2-sparc/include/plain
RMLINCLUDE = /home/pelab/pub/pkg/rml/current/sparc-sol2-gcc/include/plain

TOKENS = tokens.h
#
Expand All @@ -19,7 +19,9 @@ DLG_FILE = parser.dlg
ERR = err
HDR_FILE =
#PCCTS = /home/pelab/pkg/pccts
PCCTS = /home/x97davka/src/pccts
#PCCTS = /home/x97davka/src/pccts
PCCTS = /net/ent4000/files/dsk1/ida/x98petro/TMP/pcctc133m18/pccts

ANTLR_H = $(PCCTS)/h
BIN = $(PCCTS)/bin
ANTLR = $(BIN)/antlr
Expand Down
1 change: 1 addition & 0 deletions modeq/ast/attrib.c
Expand Up @@ -22,6 +22,7 @@ int zzcr_attr(Attrib *attr, int type, char *text)
attr->u.stringval[l-2] = 0;
break;
default:
fprintf("No data in attrib is set."); break;
break;
}
}
Expand Down
116 changes: 85 additions & 31 deletions modeq/ast/modgram.g
Expand Up @@ -100,10 +100,13 @@ void unimpl(char *rule)
#token PUBLIC "public"
/* #token PRIVATE "private" */
#token PROTECTED "protected"
#token COMMA ","
#token LPAR "\("
#token RPAR "\)"
#token LBRACK "\["
#token RBRACK "\]"
#token LCURL "\{"
#token RCURL "\}"
/* #token RECORD_BEGIN "\{" */
/* #token RECORD_END "\}" */
#token IF "if"
Expand Down Expand Up @@ -239,7 +242,7 @@ class_definition[bool is_replaceable,bool is_final] :
>>
| EQUALS dp:name_path
/* FIXME: grammar says array_dimensions */
{ da:array_subscripts << has_array_dim=true; >> }
{ da:array_subscripts<< has_array_dim=true; >> }
{ ds:class_modification << has_class_spec=true; >> }
<<
Attrib a = $[CLASS_,"---"];
Expand Down Expand Up @@ -320,7 +323,7 @@ extends_clause:
*/

component_clause!:
<< bool fl=false, di=false, pa=false, co=false, in=false, ou=false;
<< bool fl=false, di=false, pa=false, co=false, in=false, ou=false, has_array=false;
Attrib a = $[COMPONENTS,"---"]; >>
/* inline type_prefix for easy access to the flags */
{ f:FLOW << fl = true; >> }
Expand All @@ -330,16 +333,19 @@ component_clause!:
{ i:INPUT << in = true; >>
| o:OUTPUT << ou = true; >> }
s:type_specifier
{ as:array_subscripts << has_array=true; >> } /* Extra part for 1.1 */
l:component_list
<< #0 = #(#[&a], #p, #s, #l);
/*!! Add the array subscripts. Done */
#0->rml = Absyn__COMPONENTS(Absyn__ATTR(RML_PRIM_MKBOOL(fl),
pa ? Absyn__PARAM :
co ? Absyn__CONST :
di ? Absyn__DISCRETE :
Absyn__VAR,
di ? Absyn__DISCRETE : Absyn__VAR,
in ? Absyn__INPUT :
ou ? Absyn__OUTPUT:
Absyn__BIDIR),
Absyn__BIDIR,
has_array ? #as->rml : mk_nil() /*1.1*/
),
#s->rml,
sibling_list(#l));

Expand Down Expand Up @@ -424,7 +430,7 @@ argument :

element_modification : << bool is_final=false; >>
{ FINAL << is_final=true; >> }
cr:single_component_reference /* name_path /* Not in spec */
cr:component_reference /* name_path /* Not in spec */
sp:modification
<<
Attrib a = $[MODIFICATION,"---"];
Expand Down Expand Up @@ -469,7 +475,7 @@ component_clause1!:
Absyn__VAR,
in ? Absyn__INPUT :
ou ? Absyn__OUTPUT:
Absyn__BIDIR),
Absyn__BIDIR, mk_nil()),
#s->rml,
mk_cons(#decl->rml, mk_nil()));

Expand Down Expand Up @@ -508,23 +514,33 @@ algorithm_clause :
;

equation : << bool is_assign = false; AST *top; >>
( e1:range_expression EQUALS^ e2:expression
(

/*o 1.0 e1:range_expression EQUALS^ e2:expression */
e1:simple_expression EQUALS^ e2:expression /* 1.1 */

<< #0->rml = Absyn__EQ_5fEQUALS(#e1->rml, #e2->rml); >>
| conditional_equation_e
| for_clause_e
| when_clause_e /* 1.1*/
| connect_clause )
comment!
;

/*
left_expression :
range_expression | LPAR single_component_reference "," single_component_reference { "," single_component_reference } RPAR
;
*
*/
algorithm :
( cr:single_component_reference
( cr:component_reference
( ASSIGN^ e:expression
<< #0->rml = Absyn__ALG_5fASSIGN(#cr->rml, #e->rml); >>
| function_call << unimpl("algorithm function_call"); >> )
| conditional_equation_a
| for_clause_a
| while_clause
| when_clause )
| when_clause_a )
comment!
;

Expand Down Expand Up @@ -612,14 +628,28 @@ while_clause :
END! WHILE!
<< #wh->rml = Absyn__ALG_5fWHILE(#e->rml, sibling_list(#el)); >>
;

/*1.1*/
when_clause_e :
wh:WHEN^ e:expression DO!
el:algorithm_list
END! WHEN!
<< #wh->rml = Absyn__EQ_5fWHEN_5fE(#e->rml, sibling_list(#el)); >>
;
/*1.1*/
when_clause_a :
wh:WHEN^ e:expression DO!
el:equation_list
END! WHEN!
<< #wh->rml = Absyn__ALG_5fWHEN_5fA(#e->rml, sibling_list(#el)); >>
;
/*o 1.0
when_clause :
wh:WHEN^ e:expression DO!
el:algorithm_list
END! WHEN!
<< #wh->rml = Absyn__ALG_5fWHEN(#e->rml, sibling_list(#el)); >>
;

*/
equation_list :
( equation ";"! )*
;
Expand Down Expand Up @@ -744,24 +774,42 @@ factor :
#e2->rml); >> }
;

primary : << bool is_matrix; >>
primary : << bool is_matrix; void* parts;>>
ni:UNSIGNED_INTEGER
<< #ni->rml = Absyn__INTEGER(mk_icon($ni.u.ival)); >>
| nr:UNSIGNED_REAL
<< #nr->rml = Absyn__REAL(mk_rcon($nr.u.realval)); >>
| f:FALS/*E*/ << #f->rml = Absyn__BOOL(RML_FALSE); >>
<< #nr->rml = Absyn__REAL(mk_rcon($nr.u.realval));
printf("Parse>> RealValue read: %f", $nr.u.realval);

>>
| s:STRING << #s->rml = Absyn__STRING(mk_scon($s.u.stringval)); >>
| f:FALS/*E*/ << #f->rml = Absyn__BOOL(RML_FALSE); >>
| t:TRU/*E*/ << #t->rml = Absyn__BOOL(RML_TRUE); >>
/* | (name_path_function_arguments)? */
/* | i:single_component_reference
{ fc:function_call }
<< if(#fc)

| i:component_reference { fc:function_call }
<< if(#fc)
#0->rml = Absyn__CALL(#i->rml,#fc->rml);
else
#0->rml = Absyn__CREF(#i->rml);
>>
*/
| component_references
| s:STRING << #s->rml = Absyn__STRING(mk_scon($s.u.stringval)); >>

/* Modelica 1.1. Meaning se spec. page 19 */
/* Mutiple return values from functions. */
| par:LPAR^ e:expression_list RPAR!
<<
/* Attrib a = $[TUPLE_,"---"];
#0 = #(#[&a], #0);*/
parts=sibling_list(#e);
#0->rml=Absyn__TUPLE(parts);


>>

| LBRACK expression_list { ";"! expression_list } RBRACK
| LCURL expression_list RCURL


/*o 1.0
| par:LPAR^
e:expression RPAR!
<< #par->rml = #e->rml; >>
Expand All @@ -772,12 +820,12 @@ primary : << bool is_matrix; >>
#0->rml = Absyn__MATRIX(#c->rml);
} else {
#0->rml = Absyn__ARRAY(#c->rml);
/* #0->rml = Absyn__MATRIX(mk_cons(#c->rml, mk_nil()));*/
}
>>
RBRACK!
;

*/
;
/*
component_references:
single_component_reference { function_or_multiple_references }
;
Expand All @@ -786,6 +834,7 @@ function_or_multiple_references:
function_call
| "," single_component_reference { "," single_component_reference }
;
*/

/* name_path_function_arguments ! : << Attrib a = $[FUNCALL,"---"]; >> */
/* n:name_path f:function_arguments */
Expand Down Expand Up @@ -813,10 +862,10 @@ name_path : << bool qualified = false; >>
/* name_path b:LBRACK^ subscript_list RBRACK! */
/* ; */

single_component_reference : << void *tail = NULL;>>
component_reference : << void *tail = NULL;>>
i:IDENT^ { a:array_subscripts }
<< #i->rml = mk_scon($i.u.stringval); >>
{ dot:DOT^ c:single_component_reference << tail = #c->rml; >> }
{ dot:DOT^ c:component_reference << tail = #c->rml; >> }
<< if(tail)
#0->rml = Absyn__CREF_5fQUAL(#i->rml, #a?#a->rml:mk_nil(), tail);
else
Expand All @@ -829,6 +878,7 @@ function_call :
;

/* not in document's grammar */
/*
column_expression > [bool is_matrix] :
<< $is_matrix=false; >>
e:row_expression ( ";"! row_expression << $is_matrix=true; >> )*
Expand All @@ -838,18 +888,22 @@ column_expression > [bool is_matrix] :
#0->rml = sibling_list(#e);
} >>
;
*/
/*!! 1.1*/
expression_list :
expression (COMMA! expression)* ;

row_expression :
/* 1.0 row_expression :
e:expression
( ","! expression
)*
<< Attrib a = $[ROW,"---"];
#0 = #(#[&a], #e);
#0->rml = sibling_list(#e); >>
;

*/
function_arguments :
expression ( ","! expression )*
expression_list
| IDENT EQUALS^ expression (","! IDENT EQUALS^ expression)*
<< unimpl("function_arguments (named parameters)"); >>
;
Expand Down
2 changes: 1 addition & 1 deletion modeq/runtime/Makefile
Expand Up @@ -6,7 +6,7 @@
# $Id$
#

RMLINCLUDE = /home/pelab/pub/pkg/rml/current/sol2-sparc/include/plain
RMLINCLUDE = /home/pelab/pub/pkg/rml/current/sparc-sol2-gcc/include/plain

SHELL = /bin/sh
CC = cc
Expand Down

0 comments on commit a1071c8

Please sign in to comment.