View Issue Details

IDProjectCategoryView StatusLast Update
0000450ascendcompilerpublic2013-02-26 13:39
Reporterjohn 
Assigned Tojohn 
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version0.9.7 
Target Version0.9.9Fixed in Version 
Summary0000450: Add support for combined FIX and assignment statment
DescriptionOften while writing models one wishes to do something like

FIX myvar := 300 {K};

This syntax is not currently supported, and instead one must type the rather more wordy

FIX myvar;
myvar := 300 {K};

Fixing this would be a very simple fix, and would improve model readability and usability.

TagsNo tags attached.

Relationships

Activities

Ksenija

2011-09-04 17:26

developer  

fix_and_assign.patch (1,566 bytes)
Index: ascend/compiler/ascParse.y
===================================================================
--- ascend/compiler/ascParse.y	(revision 3807)
+++ ascend/compiler/ascParse.y	(working copy)
@@ -405,7 +405,7 @@
 %type <swptr> switchlist switchlistf
 %type <wptr> whenlist whenlistf
 %type <notesptr> notes_body noteslist
-%type <listp> methods proclist proclistf statements unitdeflist
+%type <listp> methods proclist proclistf statements unitdeflist fix_and_assign_statement complex_statement
 %type <procptr> procedure
 %type <dimp> dims dimensions
 %type <dimen> dimexpr
@@ -1226,6 +1226,11 @@
 	  }
 	  $$ = $1;
 	}
+    | statements complex_statement ';'
+	{
+	  gl_append_list($1,$2);
+	  $$ = $1;
+	}
     | statements error ';'
 	{
 	  ErrMsg_Generic("Error in statement input.");
@@ -1269,6 +1274,10 @@
 	| units_statement
 	;
 
+complex_statement:
+	fix_and_assign_statement
+	;
+
 isa_statement:
     fvarlist ISA_TOK type_identifier optional_of optional_with_value
 	{
@@ -1749,8 +1758,22 @@
 		/*CONSOLE_DEBUG("GOT 'FIX' STATEMENT...");*/
 		$$ = CreateFIX($2);
 	}
	;
 
+fix_and_assign_statement:
+	FIX_TOK assignment_statement
+	{
+		struct Statement *assign = $2;
+		struct Name *n = $2 -> v.asgn.nptr;
+		struct VariableList *vars = CreateVariableNode(n);
+		struct Statement *fix = CreateFIX(ReverseVariableList(vars));
+		struct gl_list_t *fix_and_assign = gl_create(2);
+		gl_append_ptr(fix_and_assign,(char*)fix);
+		gl_append_ptr(fix_and_assign,(char*)assign);
+		$$ = fix_and_assign;
+	}
+     ;
+
 free_statement:
 	FREE_TOK fvarlist
 	{
fix_and_assign.patch (1,566 bytes)

Ksenija

2011-09-04 17:27

developer   ~0000770

I have submitted a patch that adds support for combined fix and assignment statement.

Ksenija

2011-09-20 03:59

developer  

fix_and_assign1.patch (1,617 bytes)
Index: ascend/compiler/ascParse.y
===================================================================
--- ascend/compiler/ascParse.y	(revision 3828)
+++ ascend/compiler/ascParse.y	(working copy)
@@ -405,7 +405,7 @@
 %type <swptr> switchlist switchlistf
 %type <wptr> whenlist whenlistf
 %type <notesptr> notes_body noteslist
-%type <listp> methods proclist proclistf statements unitdeflist
+%type <listp> methods proclist proclistf statements unitdeflist fix_and_assign_statement complex_statement
 %type <procptr> procedure
 %type <dimp> dims dimensions
 %type <dimen> dimexpr
@@ -1226,6 +1226,13 @@
 	  }
 	  $$ = $1;
 	}
+    | statements complex_statement ';'
+	{
+	  if ($2 != NULL) {
+	    gl_append_list($1,$2);
+	  }
+	  $$ = $1;
+	}
     | statements error ';'
 	{
 	  ErrMsg_Generic("Error in statement input.");
@@ -1269,6 +1276,10 @@
 	| units_statement
 	;
 
+complex_statement:
+	fix_and_assign_statement
+	;
+
 isa_statement:
     fvarlist ISA_TOK type_identifier optional_of optional_with_value
 	{
@@ -1749,8 +1760,22 @@
 		/*CONSOLE_DEBUG("GOT 'FIX' STATEMENT...");*/
 		$$ = CreateFIX($2);
 	}
-	;
+       ;
 
+fix_and_assign_statement:
+	FIX_TOK assignment_statement
+	{
+		struct Statement *assign = $2;
+		struct Name *n = CopyName($2 -> v.asgn.nptr);
+		struct VariableList *vars = CreateVariableNode(n);
+		struct Statement *fix = CreateFIX(ReverseVariableList(vars));
+		struct gl_list_t *fix_and_assign = gl_create(7L);
+		gl_append_ptr(fix_and_assign,(char*)fix);
+		gl_append_ptr(fix_and_assign,(char*)assign);
+		$$ = fix_and_assign;
+	}
+     ;
+
 free_statement:
 	FREE_TOK fvarlist
 	{
fix_and_assign1.patch (1,617 bytes)

Ksenija

2011-09-20 04:01

developer   ~0000771

A little correction of the first patch.

john

2011-11-11 16:06

administrator   ~0000782

Is that all the changes that are required? I would have imagined changes elsewhere also to be required. Please provide a CUnit test case for us to check it with.

john

2011-11-13 22:38

administrator   ~0000792

Ksenija has checked in changes for this as changeset 3853 http://ascend4.org/r3853.

Issue History

Date Modified Username Field Change
2010-04-07 17:16 john New Issue
2010-04-07 17:16 john Target Version => 0.9.8
2010-07-31 13:27 john Target Version 0.9.8 => 1.0
2011-09-04 17:26 Ksenija File Added: fix_and_assign.patch
2011-09-04 17:27 Ksenija Note Added: 0000770
2011-09-20 03:59 Ksenija File Added: fix_and_assign1.patch
2011-09-20 04:01 Ksenija Note Added: 0000771
2011-11-11 16:06 john Note Added: 0000782
2011-11-13 22:38 john Note Added: 0000792
2011-11-13 22:39 john Assigned To => john
2011-11-13 22:39 john Status new => feedback
2011-11-15 23:41 svn
2012-02-04 06:05 svn
2012-02-04 06:06 svn Status feedback => resolved
2012-02-04 06:06 svn Resolution open => fixed
2013-02-26 13:39 john Target Version 1.0 => 0.9.9