diff options
author | Sunil Shetye | 2018-06-16 07:43:22 +0530 |
---|---|---|
committer | Sunil Shetye | 2018-06-16 07:43:22 +0530 |
commit | 4a602cc59c9bc5a888e50caa40776e4fb5e7b852 (patch) | |
tree | 0243ed143d24184c23e1db0fce2d2df1d4d79872 | |
parent | 38abf05b46c55e66c58633cdc6d179bddec30c00 (diff) | |
download | sci2js-4a602cc59c9bc5a888e50caa40776e4fb5e7b852.tar.gz sci2js-4a602cc59c9bc5a888e50caa40776e4fb5e7b852.tar.bz2 sci2js-4a602cc59c9bc5a888e50caa40776e4fb5e7b852.zip |
support part(variable, expression) syntax
-rw-r--r-- | combined.js | 411 | ||||
-rw-r--r-- | js/Misc/CBLOCK.js | 2 | ||||
-rw-r--r-- | js/Misc/CBLOCK4.js | 111 | ||||
-rw-r--r-- | js/Misc/generic_block.js | 98 | ||||
-rw-r--r-- | js/Misc/generic_block2.js | 100 | ||||
-rw-r--r-- | js/Misc/generic_block3.js | 104 | ||||
-rw-r--r-- | js/Sinks/WFILE_f.js | 2 | ||||
-rw-r--r-- | js/Sources/RFILE_f.js | 2 | ||||
-rwxr-xr-x | sci2jsyacc.py | 9 |
9 files changed, 825 insertions, 14 deletions
diff --git a/combined.js b/combined.js index 59250d1f..edc62903 100644 --- a/combined.js +++ b/combined.js @@ -10979,6 +10979,103 @@ x=standard_define([3,2],model,exprs,gr_i); CONSTRAINT2_c.prototype.details = function CONSTRAINT2_c() { } } +/* autogenerated from "macros/Misc/generic_block.sci" */ +function generic_block() { +generic_block.prototype.get = function generic_block() { +} +generic_block.prototype.set = function generic_block() { +x=arg1; +model=arg1.model; +graphics=arg1.graphics; +label=graphics.exprs; +if (size(label,"*")==14) { +label[9-1]=[]; +} +while (true) { +[ok,function_name,funtyp,i,o,ci,co,xx,z,rpar,ipar,auto0,depu,dept,lab]=scicos_getvalue("Set GENERIC block parameters",["simulation function","function type (0,1,2,..)","input ports sizes","output port sizes","input event ports sizes","output events ports sizes","initial continuous state","initial discrete state","Real parameters vector","Integer parameters vector","initial firing vector (<0 for no firing)","direct feedthrough (y or n)","time dependence (y or n)"],list("str",1,"vec",1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec","sum(%6)","str",1,"str",1),label); +if (!ok) { +break +} +label=lab; +function_name=stripblanks(function_name); +xx=xx.slice(); +z=z.slice(); +rpar=rpar.slice(); +ipar=int(ipar.slice()); +i=int(i.slice()); +o=int(o.slice()); +ci=int(ci.slice()); +co=int(co.slice()); +funtyp=int(funtyp); +if (funtyp<0) { +message("function type cannot be negative"); +ok=None; +} +if ([ci,co]!=[]) { +if (max([ci,co])>1) { +message("vector event links not supported"); +ok=None; +} +} +depu=stripblanks(depu); +if (part(depu,1)=="y") { +depu=true; +} else { +depu=None; +} +dept=stripblanks(dept); +if (part(dept,1)=="y") { +dept=true; +} else { +dept=None; +} +dep_ut=[depu,dept]; +if (ok) { +[model,graphics,ok]=check_io(model,graphics,i,o,ci,co); +} +if (ok) { +if (funtyp==3) { +needcompile=4; +} +model.sim=list(function_name,funtyp); +model.state=xx; +model.dstate=z; +model.rpar=rpar; +model.ipar=ipar; +model.firing=auto0; +model.dep_ut=dep_ut; +arg1.model=model; +graphics.exprs=label; +arg1.graphics=graphics; +x=arg1; +break +} +} +needcompile=resume(needcompile) +} +generic_block.prototype.define = function generic_block() { +model=scicos_model(); +function_name="sinblk"; +funtyp=1; +model.sim=list(function_name,funtyp); +model.in1=1; +model.out=1; +model.evtin=[]; +model.evtout=[]; +model.state=[]; +model.dstate=[]; +model.rpar=[]; +model.ipar=[]; +model.blocktype="c"; +model.firing=[]; +model.dep_ut=[true,None]; +label=[function_name,sci2exp(funtyp),sci2exp(model.in1),sci2exp(model.out),sci2exp(model.evtin),sci2exp(model.evtout),sci2exp(model.state),sci2exp(model.dstate),sci2exp(model.rpar),sci2exp(model.ipar),sci2exp(model.firing),"y","n"]; +gr_i=[]; +x=standard_define([2,2],model,label,gr_i); +} +generic_block.prototype.details = function generic_block() { +} +} /* autogenerated from "macros/Misc/RATELIMITER.sci" */ function RATELIMITER() { RATELIMITER.prototype.get = function RATELIMITER() { @@ -11238,6 +11335,208 @@ x.graphics.out_implicit=["I","I"]; IMPSPLIT_f.prototype.details = function IMPSPLIT_f() { } } +/* autogenerated from "macros/Misc/generic_block2.sci" */ +function generic_block2() { +generic_block2.prototype.get = function generic_block2() { +} +generic_block2.prototype.set = function generic_block2() { +x=arg1; +model=arg1.model; +graphics=arg1.graphics; +label=graphics.exprs; +if (size(label,"*")==14) { +label[9-1]=[]; +} +while (true) { +[ok,function_name,funtyp,i,o,ci,co,xx,z,rpar,ipar,nmode,nzcr,auto0,depu,dept,lab]=scicos_getvalue("Set GENERIC block parameters",["simulation function","function type (0,1,2,..)","input ports sizes","output port sizes","input event ports sizes","output events ports sizes","initial continuous state","initial discrete state","Real parameters vector","Integer parameters vector","number of modes","number of zero_crossings","initial firing vector (<0 for no firing)","direct feedthrough (y or n)","time dependence (y or n)"],list("str",1,"vec",1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",1,"vec",1,"vec","sum(%6)","str",1,"str",1),label); +if (!ok) { +break +} +label=lab; +function_name=stripblanks(function_name); +xx=xx.slice(); +z=z.slice(); +rpar=rpar.slice(); +ipar=int(ipar.slice()); +i=int(i.slice()); +o=int(o.slice()); +ci=int(ci.slice()); +co=int(co.slice()); +funtyp=int(funtyp); +if (funtyp<0) { +message("function type cannot be negative"); +ok=None; +} +if ([ci,co]!=[]) { +if (max([ci,co])>1) { +message("vector event links not supported"); +ok=None; +} +} +depu=stripblanks(depu); +if (part(depu,1)=="y") { +depu=true; +} else { +depu=None; +} +dept=stripblanks(dept); +if (part(dept,1)=="y") { +dept=true; +} else { +dept=None; +} +dep_ut=[depu,dept]; +if (ok) { +[model,graphics,ok]=check_io(model,graphics,i,o,ci,co); +} +if (ok) { +if (funtyp==3) { +needcompile=4; +} +model.sim=list(function_name,funtyp); +model.state=xx; +model.dstate=z; +model.rpar=rpar; +model.ipar=ipar; +model.firing=auto0; +model.nzcross=nzcr; +model.nmode=nmode; +model.dep_ut=dep_ut; +arg1.model=model; +graphics.exprs=label; +arg1.graphics=graphics; +x=arg1; +break +} +} +needcompile=resume(needcompile) +} +generic_block2.prototype.define = function generic_block2() { +model=scicos_model(); +function_name="sinblk"; +funtyp=1; +model.sim=list(function_name,funtyp); +model.in1=1; +model.out=1; +model.evtin=[]; +model.evtout=[]; +model.state=[]; +model.dstate=[]; +model.rpar=[]; +model.ipar=[]; +model.blocktype="c"; +model.firing=[]; +model.dep_ut=[true,None]; +label=[function_name,sci2exp(funtyp),sci2exp(model.in1),sci2exp(model.out),sci2exp(model.evtin),sci2exp(model.evtout),sci2exp(model.state),sci2exp(model.dstate),sci2exp(model.rpar),sci2exp(model.ipar),sci2exp(model.nmode),sci2exp(model.nzcross),sci2exp(model.firing),"y","n"]; +gr_i=[]; +x=standard_define([2,2],model,label,gr_i); +} +generic_block2.prototype.details = function generic_block2() { +} +} +/* autogenerated from "macros/Misc/generic_block3.sci" */ +function generic_block3() { +generic_block3.prototype.get = function generic_block3() { +} +generic_block3.prototype.set = function generic_block3() { +x=arg1; +model=arg1.model; +graphics=arg1.graphics; +label=graphics.exprs; +if (size(label,"*")==14) { +label[9-1]=[]; +} +while (true) { +[ok,function_name,funtyp,in1,it,out,ot,ci,co,xx,z,oz,rpar,ipar,opar,nmode,nzcr,auto0,depu,dept,lab]=scicos_getvalue("Set GENERIC block parameters",["Simulation function","Function type (0,1,2,..)","Input ports sizes","Input ports type","Output port sizes","Output ports type","Input event ports sizes","Output events ports sizes","Initial continuous state","Initial discrete state","Initial object state","Real parameters vector","Integer parameters vector","Object parameters list","Number of modes","Number of zero crossings","Initial firing vector (<0 for no firing)","Direct feedthrough (y or n)","Time dependence (y or n)"],list("str",1,"vec",1,"mat",[-1,2],"vec",-1,"mat",[-1,2],"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"lis",-1,"vec",-1,"vec",-1,"lis",-1,"vec",1,"vec",1,"vec","sum(%8)","str",1,"str",1),label); +if (!ok) { +break +} +label=lab; +function_name=stripblanks(function_name); +xx=xx.slice(); +z=z.slice(); +rpar=rpar.slice(); +ipar=int(ipar.slice()); +ci=int(ci.slice()); +co=int(co.slice()); +funtyp=funtyp; +if (funtyp<0) { +message("function type cannot be negative"); +ok=None; +} +if ([ci,co]!=[]) { +if (max([ci,co])>1) { +message("vector event links not supported"); +ok=None; +} +} +if (type(opar)!=15) { +message("object parameter must be a list"); +ok=None; +} +if (type(oz)!=15) { +message("discrete object state must be a list"); +ok=None; +} +depu=stripblanks(depu); +if (part(depu,1)=="y") { +depu=true; +} else { +depu=None; +} +dept=stripblanks(dept); +if (part(dept,1)=="y") { +dept=true; +} else { +dept=None; +} +dep_ut=[depu,dept]; +if (ok) { +[model,graphics,ok]=set_io(model,graphics,list(in1,it),list(out,ot),ci,co); +} +if (ok) { +if (funtyp==3) { +needcompile=4; +} +model.sim=list(function_name,funtyp); +model.state=xx; +model.dstate=z; +model.odstate=oz; +model.rpar=rpar; +model.ipar=ipar; +model.opar=opar; +model.firing=auto0; +model.nzcross=nzcr; +model.nmode=nmode; +model.dep_ut=dep_ut; +arg1.model=model; +graphics.exprs=label; +arg1.graphics=graphics; +x=arg1; +break +} +} +needcompile=resume(needcompile) +} +generic_block3.prototype.define = function generic_block3() { +model=scicos_model(); +function_name="sinblk"; +funtyp=4; +model.sim=list(function_name,funtyp); +model.in1=1; +model.in2=1; +model.intyp=1; +model.out=1; +model.out2=1; +model.outtyp=1; +model.dep_ut=[true,None]; +label=[function_name,sci2exp(funtyp),sci2exp([model.in1,model.in2]),sci2exp(model.intyp),sci2exp([model.out,model.out2]),sci2exp(model.outtyp),sci2exp(model.evtin),sci2exp(model.evtout),sci2exp(model.state),sci2exp(model.dstate),sci2exp(model.odstate),sci2exp(model.rpar),sci2exp(model.ipar),sci2exp(model.opar),sci2exp(model.nmode),sci2exp(model.nzcross),sci2exp(model.firing),"y","n"]; +gr_i=[]; +x=standard_define([4,2],model,label,gr_i); +} +generic_block3.prototype.details = function generic_block3() { +} +} /* autogenerated from "macros/Misc/DEBUG_SCICOS.sci" */ function DEBUG_SCICOS() { DEBUG_SCICOS.prototype.get = function DEBUG_SCICOS() { @@ -11357,6 +11656,116 @@ x=mlist(["Text","graphics","model","void","gui"],graphics,model," ","TEXT_f"); TEXT_f.prototype.details = function TEXT_f() { } } +/* autogenerated from "macros/Misc/CBLOCK4.sci" */ +function CBLOCK4() { +CBLOCK4.prototype.get = function CBLOCK4() { +} +CBLOCK4.prototype.set = function CBLOCK4() { +x=arg1; +model=arg1.model; +graphics=arg1.graphics; +label=graphics.exprs; +while (true) { +[ok,function_name,impli,in1,it,out,ot,ci,co,xx,z,oz,rpar,ipar,opar,nmode,nzcr,auto0,depu,dept,lab]=scicos_getvalue("Set C-Block4 block parameters",["Simulation function","Is block implicit? (y,n)","Input ports sizes","Input ports type","Output port sizes","Output ports type","Input event ports sizes","Output events ports sizes","Initial continuous state","Initial discrete state","Initial object state","Real parameters vector","Integer parameters vector","Object parameters list","Number of modes","Number of zero crossings","Initial firing vector (<0 for no firing)","Direct feedthrough (y or n)","Time dependence (y or n)"],list("str",1,"str",1,"mat",[-1,2],"vec",-1,"mat",[-1,2],"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"lis",-1,"vec",-1,"vec",-1,"lis",-1,"vec",1,"vec",1,"vec","sum(%8)","str",1,"str",1),label(1)); +if (!ok) { +break +} +label[1-1]=lab; +funam=stripblanks(function_name); +xx=xx.slice(); +z=z.slice(); +rpar=rpar.slice(); +ipar=int(ipar.slice()); +nx=size(xx,1); +nz=size(z,1); +ci=int(ci.slice()); +nevin=size(ci,1); +co=int(co.slice()); +nevout=size(co,1); +if (part(impli,1)=="y") { +funtyp=12004; +} else { +funtyp=2004; +} +if ([ci,co]!=[]) { +if (max([ci,co])>1) { +message("vector event links not supported"); +ok=None; +} +} +if (ok) { +depu=stripblanks(depu); +if (part(depu,1)=="y") { +depu=true; +} else { +depu=None; +} +dept=stripblanks(dept); +if (part(dept,1)=="y") { +dept=true; +} else { +dept=None; +} +dep_ut=[depu,dept]; +if (funam==" ") { +break +} +if (model.sim(1)!=funam||sign(size(model.state,"*"))!=sign(nx)||sign(size(model.dstate,"*"))!=sign(nz)||model.nzcross!=nzcr||sign(size(model.evtout,"*"))!=sign(nevout)) { +tt=[]; +} +tt=label[2-1]; +[model,graphics,ok]=set_io(model,graphics,list(in1,it),list(out,ot),ci,co); +} +if (ok) { +while (true) { +[ok,tt,cancel]=CC4(funam,tt); +if (!ok) { +if (cancel) { +break +} +} else { +model.sim=list(funam,funtyp); +model.state=xx; +model.dstate=z; +model.odstate=oz; +model.rpar=rpar; +model.ipar=ipar; +model.opar=opar; +model.firing=auto0; +model.nzcross=nzcr; +model.nmode=nmode; +model.dep_ut=dep_ut; +label[2-1]=tt; +x.model=model; +graphics.exprs=label; +x.graphics=graphics; +break +} +} +if (ok||cancel) { +break +} +} +} +} +CBLOCK4.prototype.define = function CBLOCK4() { +funam="toto"; +model=scicos_model(); +model.sim=list(" ",2004); +model.in1=1; +model.in2=1; +model.intyp=1; +model.out=1; +model.out2=1; +model.outtyp=1; +model.dep_ut=[true,None]; +label=list([funam,"n",sci2exp([model.in1,model.in2]),sci2exp(model.intyp),sci2exp([model.out,model.out2]),sci2exp(model.outtyp),sci2exp(model.evtin),sci2exp(model.evtout),sci2exp(model.state),sci2exp(model.dstate),sci2exp(model.odstate),sci2exp(model.rpar),sci2exp(model.ipar),sci2exp(model.opar),sci2exp(model.nmode),sci2exp(model.nzcross),sci2exp(model.firing),"y","n"],[]); +gr_i=[]; +x=standard_define([4,2],model,label,gr_i); +} +CBLOCK4.prototype.details = function CBLOCK4() { +} +} /* autogenerated from "macros/Misc/BOUNCEXY.sci" */ function BOUNCEXY() { BOUNCEXY.prototype.get = function BOUNCEXY() { @@ -13768,4 +14177,4 @@ INVBLK_f.prototype.details = function INVBLK_f() { } } -/* made from 228/274 files */ +/* made from 232/274 files */ diff --git a/js/Misc/CBLOCK.js b/js/Misc/CBLOCK.js index cc93a55b..b85b314b 100644 --- a/js/Misc/CBLOCK.js +++ b/js/Misc/CBLOCK.js @@ -1,3 +1,3 @@ -Syntax error in input LexToken(CLOSEBRACKET,')',1,2476) +Syntax error in input LexToken(TRANSPOSE,"'",1,5385) /* autogenerated from "macros/Misc/CBLOCK.sci" */ None diff --git a/js/Misc/CBLOCK4.js b/js/Misc/CBLOCK4.js index 56c3e022..8b981a0b 100644 --- a/js/Misc/CBLOCK4.js +++ b/js/Misc/CBLOCK4.js @@ -1,3 +1,110 @@ -Syntax error in input LexToken(CLOSEBRACKET,')',1,2684) /* autogenerated from "macros/Misc/CBLOCK4.sci" */ -None +function CBLOCK4() { +CBLOCK4.prototype.get = function CBLOCK4() { +} +CBLOCK4.prototype.set = function CBLOCK4() { +x=arg1; +model=arg1.model; +graphics=arg1.graphics; +label=graphics.exprs; +while (true) { +[ok,function_name,impli,in1,it,out,ot,ci,co,xx,z,oz,rpar,ipar,opar,nmode,nzcr,auto0,depu,dept,lab]=scicos_getvalue("Set C-Block4 block parameters",["Simulation function","Is block implicit? (y,n)","Input ports sizes","Input ports type","Output port sizes","Output ports type","Input event ports sizes","Output events ports sizes","Initial continuous state","Initial discrete state","Initial object state","Real parameters vector","Integer parameters vector","Object parameters list","Number of modes","Number of zero crossings","Initial firing vector (<0 for no firing)","Direct feedthrough (y or n)","Time dependence (y or n)"],list("str",1,"str",1,"mat",[-1,2],"vec",-1,"mat",[-1,2],"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"lis",-1,"vec",-1,"vec",-1,"lis",-1,"vec",1,"vec",1,"vec","sum(%8)","str",1,"str",1),label(1)); +if (!ok) { +break +} +label[1-1]=lab; +funam=stripblanks(function_name); +xx=xx.slice(); +z=z.slice(); +rpar=rpar.slice(); +ipar=int(ipar.slice()); +nx=size(xx,1); +nz=size(z,1); +ci=int(ci.slice()); +nevin=size(ci,1); +co=int(co.slice()); +nevout=size(co,1); +if (part(impli,1)=="y") { +funtyp=12004; +} else { +funtyp=2004; +} +if ([ci,co]!=[]) { +if (max([ci,co])>1) { +message("vector event links not supported"); +ok=None; +} +} +if (ok) { +depu=stripblanks(depu); +if (part(depu,1)=="y") { +depu=true; +} else { +depu=None; +} +dept=stripblanks(dept); +if (part(dept,1)=="y") { +dept=true; +} else { +dept=None; +} +dep_ut=[depu,dept]; +if (funam==" ") { +break +} +if (model.sim(1)!=funam||sign(size(model.state,"*"))!=sign(nx)||sign(size(model.dstate,"*"))!=sign(nz)||model.nzcross!=nzcr||sign(size(model.evtout,"*"))!=sign(nevout)) { +tt=[]; +} +tt=label[2-1]; +[model,graphics,ok]=set_io(model,graphics,list(in1,it),list(out,ot),ci,co); +} +if (ok) { +while (true) { +[ok,tt,cancel]=CC4(funam,tt); +if (!ok) { +if (cancel) { +break +} +} else { +model.sim=list(funam,funtyp); +model.state=xx; +model.dstate=z; +model.odstate=oz; +model.rpar=rpar; +model.ipar=ipar; +model.opar=opar; +model.firing=auto0; +model.nzcross=nzcr; +model.nmode=nmode; +model.dep_ut=dep_ut; +label[2-1]=tt; +x.model=model; +graphics.exprs=label; +x.graphics=graphics; +break +} +} +if (ok||cancel) { +break +} +} +} +} +CBLOCK4.prototype.define = function CBLOCK4() { +funam="toto"; +model=scicos_model(); +model.sim=list(" ",2004); +model.in1=1; +model.in2=1; +model.intyp=1; +model.out=1; +model.out2=1; +model.outtyp=1; +model.dep_ut=[true,None]; +label=list([funam,"n",sci2exp([model.in1,model.in2]),sci2exp(model.intyp),sci2exp([model.out,model.out2]),sci2exp(model.outtyp),sci2exp(model.evtin),sci2exp(model.evtout),sci2exp(model.state),sci2exp(model.dstate),sci2exp(model.odstate),sci2exp(model.rpar),sci2exp(model.ipar),sci2exp(model.opar),sci2exp(model.nmode),sci2exp(model.nzcross),sci2exp(model.firing),"y","n"],[]); +gr_i=[]; +x=standard_define([4,2],model,label,gr_i); +} +CBLOCK4.prototype.details = function CBLOCK4() { +} +} diff --git a/js/Misc/generic_block.js b/js/Misc/generic_block.js index 7609b263..e705ee28 100644 --- a/js/Misc/generic_block.js +++ b/js/Misc/generic_block.js @@ -1,3 +1,97 @@ -Syntax error in input LexToken(CLOSEBRACKET,')',1,2771) /* autogenerated from "macros/Misc/generic_block.sci" */ -None +function generic_block() { +generic_block.prototype.get = function generic_block() { +} +generic_block.prototype.set = function generic_block() { +x=arg1; +model=arg1.model; +graphics=arg1.graphics; +label=graphics.exprs; +if (size(label,"*")==14) { +label[9-1]=[]; +} +while (true) { +[ok,function_name,funtyp,i,o,ci,co,xx,z,rpar,ipar,auto0,depu,dept,lab]=scicos_getvalue("Set GENERIC block parameters",["simulation function","function type (0,1,2,..)","input ports sizes","output port sizes","input event ports sizes","output events ports sizes","initial continuous state","initial discrete state","Real parameters vector","Integer parameters vector","initial firing vector (<0 for no firing)","direct feedthrough (y or n)","time dependence (y or n)"],list("str",1,"vec",1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec","sum(%6)","str",1,"str",1),label); +if (!ok) { +break +} +label=lab; +function_name=stripblanks(function_name); +xx=xx.slice(); +z=z.slice(); +rpar=rpar.slice(); +ipar=int(ipar.slice()); +i=int(i.slice()); +o=int(o.slice()); +ci=int(ci.slice()); +co=int(co.slice()); +funtyp=int(funtyp); +if (funtyp<0) { +message("function type cannot be negative"); +ok=None; +} +if ([ci,co]!=[]) { +if (max([ci,co])>1) { +message("vector event links not supported"); +ok=None; +} +} +depu=stripblanks(depu); +if (part(depu,1)=="y") { +depu=true; +} else { +depu=None; +} +dept=stripblanks(dept); +if (part(dept,1)=="y") { +dept=true; +} else { +dept=None; +} +dep_ut=[depu,dept]; +if (ok) { +[model,graphics,ok]=check_io(model,graphics,i,o,ci,co); +} +if (ok) { +if (funtyp==3) { +needcompile=4; +} +model.sim=list(function_name,funtyp); +model.state=xx; +model.dstate=z; +model.rpar=rpar; +model.ipar=ipar; +model.firing=auto0; +model.dep_ut=dep_ut; +arg1.model=model; +graphics.exprs=label; +arg1.graphics=graphics; +x=arg1; +break +} +} +needcompile=resume(needcompile) +} +generic_block.prototype.define = function generic_block() { +model=scicos_model(); +function_name="sinblk"; +funtyp=1; +model.sim=list(function_name,funtyp); +model.in1=1; +model.out=1; +model.evtin=[]; +model.evtout=[]; +model.state=[]; +model.dstate=[]; +model.rpar=[]; +model.ipar=[]; +model.blocktype="c"; +model.firing=[]; +model.dep_ut=[true,None]; +label=[function_name,sci2exp(funtyp),sci2exp(model.in1),sci2exp(model.out),sci2exp(model.evtin),sci2exp(model.evtout),sci2exp(model.state),sci2exp(model.dstate),sci2exp(model.rpar),sci2exp(model.ipar),sci2exp(model.firing),"y","n"]; +gr_i=[]; +x=standard_define([2,2],model,label,gr_i); +} +generic_block.prototype.details = function generic_block() { +} +} diff --git a/js/Misc/generic_block2.js b/js/Misc/generic_block2.js index c09944f5..c3b03890 100644 --- a/js/Misc/generic_block2.js +++ b/js/Misc/generic_block2.js @@ -1,3 +1,99 @@ -Syntax error in input LexToken(CLOSEBRACKET,')',1,2870) /* autogenerated from "macros/Misc/generic_block2.sci" */ -None +function generic_block2() { +generic_block2.prototype.get = function generic_block2() { +} +generic_block2.prototype.set = function generic_block2() { +x=arg1; +model=arg1.model; +graphics=arg1.graphics; +label=graphics.exprs; +if (size(label,"*")==14) { +label[9-1]=[]; +} +while (true) { +[ok,function_name,funtyp,i,o,ci,co,xx,z,rpar,ipar,nmode,nzcr,auto0,depu,dept,lab]=scicos_getvalue("Set GENERIC block parameters",["simulation function","function type (0,1,2,..)","input ports sizes","output port sizes","input event ports sizes","output events ports sizes","initial continuous state","initial discrete state","Real parameters vector","Integer parameters vector","number of modes","number of zero_crossings","initial firing vector (<0 for no firing)","direct feedthrough (y or n)","time dependence (y or n)"],list("str",1,"vec",1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",1,"vec",1,"vec","sum(%6)","str",1,"str",1),label); +if (!ok) { +break +} +label=lab; +function_name=stripblanks(function_name); +xx=xx.slice(); +z=z.slice(); +rpar=rpar.slice(); +ipar=int(ipar.slice()); +i=int(i.slice()); +o=int(o.slice()); +ci=int(ci.slice()); +co=int(co.slice()); +funtyp=int(funtyp); +if (funtyp<0) { +message("function type cannot be negative"); +ok=None; +} +if ([ci,co]!=[]) { +if (max([ci,co])>1) { +message("vector event links not supported"); +ok=None; +} +} +depu=stripblanks(depu); +if (part(depu,1)=="y") { +depu=true; +} else { +depu=None; +} +dept=stripblanks(dept); +if (part(dept,1)=="y") { +dept=true; +} else { +dept=None; +} +dep_ut=[depu,dept]; +if (ok) { +[model,graphics,ok]=check_io(model,graphics,i,o,ci,co); +} +if (ok) { +if (funtyp==3) { +needcompile=4; +} +model.sim=list(function_name,funtyp); +model.state=xx; +model.dstate=z; +model.rpar=rpar; +model.ipar=ipar; +model.firing=auto0; +model.nzcross=nzcr; +model.nmode=nmode; +model.dep_ut=dep_ut; +arg1.model=model; +graphics.exprs=label; +arg1.graphics=graphics; +x=arg1; +break +} +} +needcompile=resume(needcompile) +} +generic_block2.prototype.define = function generic_block2() { +model=scicos_model(); +function_name="sinblk"; +funtyp=1; +model.sim=list(function_name,funtyp); +model.in1=1; +model.out=1; +model.evtin=[]; +model.evtout=[]; +model.state=[]; +model.dstate=[]; +model.rpar=[]; +model.ipar=[]; +model.blocktype="c"; +model.firing=[]; +model.dep_ut=[true,None]; +label=[function_name,sci2exp(funtyp),sci2exp(model.in1),sci2exp(model.out),sci2exp(model.evtin),sci2exp(model.evtout),sci2exp(model.state),sci2exp(model.dstate),sci2exp(model.rpar),sci2exp(model.ipar),sci2exp(model.nmode),sci2exp(model.nzcross),sci2exp(model.firing),"y","n"]; +gr_i=[]; +x=standard_define([2,2],model,label,gr_i); +} +generic_block2.prototype.details = function generic_block2() { +} +} diff --git a/js/Misc/generic_block3.js b/js/Misc/generic_block3.js index 3d9a5ef7..43748af9 100644 --- a/js/Misc/generic_block3.js +++ b/js/Misc/generic_block3.js @@ -1,3 +1,103 @@ -Syntax error in input LexToken(CLOSEBRACKET,')',1,3302) /* autogenerated from "macros/Misc/generic_block3.sci" */ -None +function generic_block3() { +generic_block3.prototype.get = function generic_block3() { +} +generic_block3.prototype.set = function generic_block3() { +x=arg1; +model=arg1.model; +graphics=arg1.graphics; +label=graphics.exprs; +if (size(label,"*")==14) { +label[9-1]=[]; +} +while (true) { +[ok,function_name,funtyp,in1,it,out,ot,ci,co,xx,z,oz,rpar,ipar,opar,nmode,nzcr,auto0,depu,dept,lab]=scicos_getvalue("Set GENERIC block parameters",["Simulation function","Function type (0,1,2,..)","Input ports sizes","Input ports type","Output port sizes","Output ports type","Input event ports sizes","Output events ports sizes","Initial continuous state","Initial discrete state","Initial object state","Real parameters vector","Integer parameters vector","Object parameters list","Number of modes","Number of zero crossings","Initial firing vector (<0 for no firing)","Direct feedthrough (y or n)","Time dependence (y or n)"],list("str",1,"vec",1,"mat",[-1,2],"vec",-1,"mat",[-1,2],"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"lis",-1,"vec",-1,"vec",-1,"lis",-1,"vec",1,"vec",1,"vec","sum(%8)","str",1,"str",1),label); +if (!ok) { +break +} +label=lab; +function_name=stripblanks(function_name); +xx=xx.slice(); +z=z.slice(); +rpar=rpar.slice(); +ipar=int(ipar.slice()); +ci=int(ci.slice()); +co=int(co.slice()); +funtyp=funtyp; +if (funtyp<0) { +message("function type cannot be negative"); +ok=None; +} +if ([ci,co]!=[]) { +if (max([ci,co])>1) { +message("vector event links not supported"); +ok=None; +} +} +if (type(opar)!=15) { +message("object parameter must be a list"); +ok=None; +} +if (type(oz)!=15) { +message("discrete object state must be a list"); +ok=None; +} +depu=stripblanks(depu); +if (part(depu,1)=="y") { +depu=true; +} else { +depu=None; +} +dept=stripblanks(dept); +if (part(dept,1)=="y") { +dept=true; +} else { +dept=None; +} +dep_ut=[depu,dept]; +if (ok) { +[model,graphics,ok]=set_io(model,graphics,list(in1,it),list(out,ot),ci,co); +} +if (ok) { +if (funtyp==3) { +needcompile=4; +} +model.sim=list(function_name,funtyp); +model.state=xx; +model.dstate=z; +model.odstate=oz; +model.rpar=rpar; +model.ipar=ipar; +model.opar=opar; +model.firing=auto0; +model.nzcross=nzcr; +model.nmode=nmode; +model.dep_ut=dep_ut; +arg1.model=model; +graphics.exprs=label; +arg1.graphics=graphics; +x=arg1; +break +} +} +needcompile=resume(needcompile) +} +generic_block3.prototype.define = function generic_block3() { +model=scicos_model(); +function_name="sinblk"; +funtyp=4; +model.sim=list(function_name,funtyp); +model.in1=1; +model.in2=1; +model.intyp=1; +model.out=1; +model.out2=1; +model.outtyp=1; +model.dep_ut=[true,None]; +label=[function_name,sci2exp(funtyp),sci2exp([model.in1,model.in2]),sci2exp(model.intyp),sci2exp([model.out,model.out2]),sci2exp(model.outtyp),sci2exp(model.evtin),sci2exp(model.evtout),sci2exp(model.state),sci2exp(model.dstate),sci2exp(model.odstate),sci2exp(model.rpar),sci2exp(model.ipar),sci2exp(model.opar),sci2exp(model.nmode),sci2exp(model.nzcross),sci2exp(model.firing),"y","n"]; +gr_i=[]; +x=standard_define([4,2],model,label,gr_i); +} +generic_block3.prototype.details = function generic_block3() { +} +} diff --git a/js/Sinks/WFILE_f.js b/js/Sinks/WFILE_f.js index 686e8e7e..589af0a0 100644 --- a/js/Sinks/WFILE_f.js +++ b/js/Sinks/WFILE_f.js @@ -1,3 +1,3 @@ -Syntax error in input LexToken(CLOSEBRACKET,')',1,3595) +Syntax error in input LexToken(EOL,'\n ',1,3640) /* autogenerated from "macros/Sinks/WFILE_f.sci" */ None diff --git a/js/Sources/RFILE_f.js b/js/Sources/RFILE_f.js index 58f41f76..2b2ac0f6 100644 --- a/js/Sources/RFILE_f.js +++ b/js/Sources/RFILE_f.js @@ -1,3 +1,3 @@ -Syntax error in input LexToken(CLOSEBRACKET,')',1,3972) +Syntax error in input LexToken(EOL,'\n ',1,4018) /* autogenerated from "macros/Sources/RFILE_f.sci" */ None diff --git a/sci2jsyacc.py b/sci2jsyacc.py index 8d2377e1..b1c6fbe4 100755 --- a/sci2jsyacc.py +++ b/sci2jsyacc.py @@ -486,11 +486,16 @@ def p_term_index(p): else: p[0] = p[1] + '(' + str(p[3]) + ')' -# A(2,3) -def p_term_part_parameters(p): +# part(x,1:10) +def p_term_part_parameter_range(p): 'term : PART OPENBRACKET expression COMMA expression COLON expression CLOSEBRACKET' p[0] = p[1] + p[2] + p[3] + ',' + p[5] + ',' + p[7] + p[8] +# part(x,1) +def p_term_part_parameter_parameter(p): + 'term : PART OPENBRACKET expression COMMA expression CLOSEBRACKET' + p[0] = p[1] + p[2] + p[3] + ',' + p[5] + p[6] + # A(2,3) def p_term_function_parameters(p): '''term : termvar OPENBRACKET list CLOSEBRACKET |