summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--combined.js108
-rw-r--r--js/Sources/RFILE_f.js107
-rwxr-xr-xsci2jslex.py57
-rwxr-xr-xsci2jsyacc.py22
4 files changed, 254 insertions, 40 deletions
diff --git a/combined.js b/combined.js
index afd2be9b..2646dc34 100644
--- a/combined.js
+++ b/combined.js
@@ -6968,6 +6968,112 @@ break;
}
}
}
+/* autogenerated from "macros/Sources/RFILE_f.sci" */
+function RFILE_f() {
+RFILE_f.prototype.define = function RFILE_f() {
+out=1;
+nout=sum(out);
+frmt="(7(e10.3,1x))";
+fname="foo";
+lunit=0;
+N=2;
+rpar=[];
+tmask=0;
+outmask=1;
+ipar=[[length(fname)],[length(frmt)],[0],[N],[_str2code(fname)],[_str2code(frmt)],[tmask],[outmask]];
+dstate=[[1],[1],[lunit],[zeros((nout)*N,1)]];
+model=scicos_model();
+model.sim="readf";
+model.out=nout;
+model.evtin=1;
+model.dstate=dstate;
+model.ipar=[[length(fname)],[length(frmt)],[0],[N],[_str2code(fname)],[_str2code(frmt)],[tmask],[outmask]];
+model.blocktype="d";
+model.dep_ut=[false,false];
+exprs=[[sci2exp([])],[sci2exp(outmask)],[fname],[frmt],[string(N)],[sci2exp(out)]];
+gr_i=[];
+x=standard_define([3,2],model,exprs,gr_i);
+}
+RFILE_f.prototype.details = function RFILE_f() {
+}
+RFILE_f.prototype.get = function RFILE_f() {
+}
+RFILE_f.prototype.set = function RFILE_f() {
+x=arg1;
+graphics=arg1.graphics;
+exprs=graphics.exprs;
+model=arg1.model;
+dstate=model.dstate;
+ipar=model.ipar;
+ievt=ipar(3);
+N=ipar(4);
+imask=5+ipar(1)+ipar(2);
+tmask=ipar(imask);
+lunit=dstate(3);
+fname=exprs[3-1];
+frmt=exprs[4-1];
+if (size(exprs,"*")>5) {
+exprs[6-1]=[];
+}
+while (true) {
+[ok,tmask1,outmask,fname1,frmt1,N,exprs]=scicos_getvalue([[msprintf(gettext("Set %s block parameters"),"RFILE_f")],[" "],[gettext("Read from an input file")],[" "],[gettext("Read is done on:")],[gettext("  - A binary file if no format given")],[gettext("  - A formatted text file if a format (fortran type) is given")]],[[gettext("Time Record Selection")],[gettext("Outputs Record Selection")],[gettext("Input File Name")],[gettext("Input Format")],[gettext("Buffer Size")]],list("vec",-1,"vec",-1,"str",1,"str",1,"vec",1),exprs);
+if (!ok) {
+break;
+}
+fname1=pathconvert(stripblanks(fname1),false,true);
+frmt1=stripblanks(frmt1);
+nout=size(outmask,"*");
+if (prod(size(tmask1))>1) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s."),gettext("Time Record Selection"),strcat(string(tmask1.slice())," ")),gettext("Empty matrix or scalar expected."));
+} else if (tmask1!=[]&&tmask1<1) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d"),gettext("Time Record Selection"),tmask1),gettext("Strictly positive integer expected."));
+} else if (lunit>0&&min(length(frmt),1)!=min(length(frmt1),1)) {
+block_parameter_error([gettext("Simulation running !!! You cannot switch <br />between formatted and unformatted")],gettext("End current simulation first."));
+} else if (lunit>0&&fname1!=fname) {
+block_parameter_error(gettext("Simulation running !!! You cannot modify \'Input File Name\'"),gettext("End current simulation first."));
+} else if (lunit>0&&size(tmask1)!=size(tmask)) {
+block_parameter_error(gettext("Simulation running !!! You cannot modify \'Time Record Selection\'"),gettext("End current simulation first."));
+} else if (fname1=="") {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s"),gettext("Input File Name"),fname1),gettext("You must provide a filename."));
+} else if (frmt1!=""&&(part(frmt1,1)!="("||part(frmt1,length(frmt1))!=")")) {
+block_parameter_error(msprintf(gettext("Wrong format for \'%s\' parameter: %s."),gettext("Input Format"),frmt1),gettext("You must enclose the format\'s string between parentheses."));
+} else if (N<2) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Buffer Size"),N),gettext("Buffer size must be at least 2."));
+} else if (nout==0) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Outputs Record Selection"),nout),gettext("You must read at least one field in record."));
+} else if (min(outmask)<1) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s"),gettext("Outputs Record Selection"),strcat(string(outmask.slice())," ")),gettext("Strictly positive indexes expected."));
+} else {
+if (tmask1==[]) {
+ievt=0;
+cout=[];
+tmask1=0;
+} else {
+ievt=1;
+cout=1;
+}
+[model,graphics,ok]=check_io(model,graphics,[],nout,1,cout);
+if (ok) {
+if (ievt==0) {
+model.firing=[];
+} else {
+model.firing=0;
+}
+ipar=[[length(fname1)],[length(frmt1)],[ievt],[N],[_str2code(fname1)],[_str2code(frmt1)],[tmask1],[outmask.slice()]];
+if (prod(size(dstate))!=(nout+ievt)*N+3) {
+dstate=[[-1],[-1],[lunit],[zeros((nout+ievt)*N,1)]];
+}
+model.dstate=dstate;
+model.ipar=ipar;
+graphics.exprs=exprs;
+x.graphics=graphics;
+x.model=model;
+break;
+}
+}
+}
+}
+}
/* autogenerated from "macros/Sources/FROMWS_c.sci" */
function FROMWS_c() {
FROMWS_c.prototype.define = function FROMWS_c() {
@@ -15953,4 +16059,4 @@ x=arg1;
}
}
-/* made from 251/274 files */
+/* made from 252/274 files */
diff --git a/js/Sources/RFILE_f.js b/js/Sources/RFILE_f.js
index 265cc7f6..a5e13f89 100644
--- a/js/Sources/RFILE_f.js
+++ b/js/Sources/RFILE_f.js
@@ -1,3 +1,106 @@
-Syntax error in input LexToken(SPACE,' ',1,5989)
/* autogenerated from "macros/Sources/RFILE_f.sci" */
-None
+function RFILE_f() {
+RFILE_f.prototype.define = function RFILE_f() {
+out=1;
+nout=sum(out);
+frmt="(7(e10.3,1x))";
+fname="foo";
+lunit=0;
+N=2;
+rpar=[];
+tmask=0;
+outmask=1;
+ipar=[[length(fname)],[length(frmt)],[0],[N],[_str2code(fname)],[_str2code(frmt)],[tmask],[outmask]];
+dstate=[[1],[1],[lunit],[zeros((nout)*N,1)]];
+model=scicos_model();
+model.sim="readf";
+model.out=nout;
+model.evtin=1;
+model.dstate=dstate;
+model.ipar=[[length(fname)],[length(frmt)],[0],[N],[_str2code(fname)],[_str2code(frmt)],[tmask],[outmask]];
+model.blocktype="d";
+model.dep_ut=[false,false];
+exprs=[[sci2exp([])],[sci2exp(outmask)],[fname],[frmt],[string(N)],[sci2exp(out)]];
+gr_i=[];
+x=standard_define([3,2],model,exprs,gr_i);
+}
+RFILE_f.prototype.details = function RFILE_f() {
+}
+RFILE_f.prototype.get = function RFILE_f() {
+}
+RFILE_f.prototype.set = function RFILE_f() {
+x=arg1;
+graphics=arg1.graphics;
+exprs=graphics.exprs;
+model=arg1.model;
+dstate=model.dstate;
+ipar=model.ipar;
+ievt=ipar(3);
+N=ipar(4);
+imask=5+ipar(1)+ipar(2);
+tmask=ipar(imask);
+lunit=dstate(3);
+fname=exprs[3-1];
+frmt=exprs[4-1];
+if (size(exprs,"*")>5) {
+exprs[6-1]=[];
+}
+while (true) {
+[ok,tmask1,outmask,fname1,frmt1,N,exprs]=scicos_getvalue([[msprintf(gettext("Set %s block parameters"),"RFILE_f")],[" "],[gettext("Read from an input file")],[" "],[gettext("Read is done on:")],[gettext("&nbsp; - A binary file if no format given")],[gettext("&nbsp; - A formatted text file if a format (fortran type) is given")]],[[gettext("Time Record Selection")],[gettext("Outputs Record Selection")],[gettext("Input File Name")],[gettext("Input Format")],[gettext("Buffer Size")]],list("vec",-1,"vec",-1,"str",1,"str",1,"vec",1),exprs);
+if (!ok) {
+break;
+}
+fname1=pathconvert(stripblanks(fname1),false,true);
+frmt1=stripblanks(frmt1);
+nout=size(outmask,"*");
+if (prod(size(tmask1))>1) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s."),gettext("Time Record Selection"),strcat(string(tmask1.slice())," ")),gettext("Empty matrix or scalar expected."));
+} else if (tmask1!=[]&&tmask1<1) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d"),gettext("Time Record Selection"),tmask1),gettext("Strictly positive integer expected."));
+} else if (lunit>0&&min(length(frmt),1)!=min(length(frmt1),1)) {
+block_parameter_error([gettext("Simulation running !!! You cannot switch <br />between formatted and unformatted")],gettext("End current simulation first."));
+} else if (lunit>0&&fname1!=fname) {
+block_parameter_error(gettext("Simulation running !!! You cannot modify \'Input File Name\'"),gettext("End current simulation first."));
+} else if (lunit>0&&size(tmask1)!=size(tmask)) {
+block_parameter_error(gettext("Simulation running !!! You cannot modify \'Time Record Selection\'"),gettext("End current simulation first."));
+} else if (fname1=="") {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s"),gettext("Input File Name"),fname1),gettext("You must provide a filename."));
+} else if (frmt1!=""&&(part(frmt1,1)!="("||part(frmt1,length(frmt1))!=")")) {
+block_parameter_error(msprintf(gettext("Wrong format for \'%s\' parameter: %s."),gettext("Input Format"),frmt1),gettext("You must enclose the format\'s string between parentheses."));
+} else if (N<2) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Buffer Size"),N),gettext("Buffer size must be at least 2."));
+} else if (nout==0) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Outputs Record Selection"),nout),gettext("You must read at least one field in record."));
+} else if (min(outmask)<1) {
+block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s"),gettext("Outputs Record Selection"),strcat(string(outmask.slice())," ")),gettext("Strictly positive indexes expected."));
+} else {
+if (tmask1==[]) {
+ievt=0;
+cout=[];
+tmask1=0;
+} else {
+ievt=1;
+cout=1;
+}
+[model,graphics,ok]=check_io(model,graphics,[],nout,1,cout);
+if (ok) {
+if (ievt==0) {
+model.firing=[];
+} else {
+model.firing=0;
+}
+ipar=[[length(fname1)],[length(frmt1)],[ievt],[N],[_str2code(fname1)],[_str2code(frmt1)],[tmask1],[outmask.slice()]];
+if (prod(size(dstate))!=(nout+ievt)*N+3) {
+dstate=[[-1],[-1],[lunit],[zeros((nout+ievt)*N,1)]];
+}
+model.dstate=dstate;
+model.ipar=ipar;
+graphics.exprs=exprs;
+x.graphics=graphics;
+x.model=model;
+break;
+}
+}
+}
+}
+}
diff --git a/sci2jslex.py b/sci2jslex.py
index 6b82b2ae..f0bb000e 100755
--- a/sci2jslex.py
+++ b/sci2jslex.py
@@ -11,13 +11,12 @@ Example: ./sci2jslex.py macros/Sinks/CSCOPE.sci > js/Sinks/CSCOPE.lex
from __future__ import print_function
-import ply.lex as lex
-import re
import sys
+import ply.lex as lex
''' keep track of how many open brackets have been encountered so far '''
-brackets = 0
-sqbrackets = 0
+BRACKET_STACK = [' ']
+LAST_BRACKET = BRACKET_STACK[-1]
''' keep current string in memory '''
qstring = ''
@@ -99,41 +98,44 @@ states = (
def t_COMMA(t):
r'[ \t]*,([ \t]*(//.*)?\n?)*'
- global afterarray, brackets
+ global afterarray
afterarray = False
- if brackets != 0:
+ if LAST_BRACKET != ' ':
return t
t.type = 'EOL'
return t
def t_SEMICOLON(t):
r'[ \t]*;([ \t]*(//.*)?\n?)*'
- global afterarray, brackets
+ global afterarray
afterarray = False
- if brackets != 0:
+ if LAST_BRACKET != ' ':
return t
t.type = 'EOL'
return t
def t_CLOSESQBRACKET(t):
r'([ \t]*\.\.+[ \t]*\n)?[ \t]*\]'
- global afterarray, brackets, sqbrackets
+ global afterarray, LAST_BRACKET
afterarray = True
- brackets -= 1
- sqbrackets -= 1
+ if BRACKET_STACK.pop() != '[':
+ print("Syntax error: Mismatched ]")
+ LAST_BRACKET = BRACKET_STACK[-1]
return t
def t_CLOSEOPENBRACKET(t):
r'[ \t]*\)\(([ \t]*(//.*)?\n?)*'
- global afterarray, brackets
+ global afterarray
afterarray = True
return t
def t_CLOSEBRACKET(t):
r'([ \t]*\.\.+[ \t]*\n)?[ \t]*\)'
- global afterarray, brackets
+ global afterarray, LAST_BRACKET
afterarray = True
- brackets -= 1
+ if BRACKET_STACK.pop() != '(':
+ print("Syntax error: Mismatched )")
+ LAST_BRACKET = BRACKET_STACK[-1]
return t
def t_COMMENT(t):
@@ -144,7 +146,6 @@ def t_NUMBER(t):
r'(\d+(\.\d*)?|\.\d+)([dDeE][+-]?\d+)?'
global afterarray
afterarray = False
- t.value = re.sub(r'[de]', r'e', t.value, flags=re.IGNORECASE)
return t
def t_PREVAR(t):
@@ -175,11 +176,11 @@ def t_LASTINDEX(t):
def t_EOL(t):
r'[ \t]*\n([ \t]*(//.*)?\n?)*'
- global afterarray, brackets
- if brackets == 0:
+ global afterarray
+ if LAST_BRACKET == ' ':
afterarray = False
return t
- if sqbrackets != 0:
+ if LAST_BRACKET == '[':
t.type = 'SPACE'
return t
@@ -203,17 +204,18 @@ def t_ADDITION(t):
def t_OPENSQBRACKET(t):
r'\[([ \t]*(//.*)?\n?)*'
- global afterarray, brackets, sqbrackets
+ global afterarray, LAST_BRACKET
afterarray = False
- brackets += 1
- sqbrackets += 1
+ LAST_BRACKET = '['
+ BRACKET_STACK.append(LAST_BRACKET)
return t
def t_OPENBRACKET(t):
r'\(([ \t]*(//.*)?\n?)*'
- global afterarray, brackets
+ global afterarray, LAST_BRACKET
afterarray = False
- brackets += 1
+ LAST_BRACKET = '('
+ BRACKET_STACK.append(LAST_BRACKET)
return t
def t_NOT(t):
@@ -242,12 +244,11 @@ def t_COLON(t):
def t_SPACE(t):
r'[ \t]+'
- global sqbrackets
- if sqbrackets != 0:
+ if LAST_BRACKET == '[':
return t
def t_error(t):
- print("Illegal character '", t.value[0], "'", sep='')
+ print("Syntax error: Illegal character '", t.value[0], "'", sep='')
t.lexer.skip(1)
def t_TRANSPOSE(t):
@@ -313,11 +314,11 @@ def t_dqstring_end(t):
return t
def t_qstring_error(t):
- print("Illegal character '", t.value[0], "' in qstring", sep='')
+ print("Syntax error: Illegal character '", t.value[0], "' in qstring", sep='')
t.lexer.skip(1)
def t_dqstring_error(t):
- print("Illegal character '", t.value[0], "' in dqstring", sep='')
+ print("Syntax error: Illegal character '", t.value[0], "' in dqstring", sep='')
t.lexer.skip(1)
lexer = lex.lex()
diff --git a/sci2jsyacc.py b/sci2jsyacc.py
index c4424bc0..ac1ef9ed 100755
--- a/sci2jsyacc.py
+++ b/sci2jsyacc.py
@@ -10,6 +10,7 @@ Example: ./sci2jsyacc.py macros/Sinks/CSCOPE.sci > js/Sinks/CSCOPE.js
from __future__ import print_function
+import re
import sys
import ply.yacc as yacc
@@ -538,8 +539,8 @@ def p_term_range(p):
# B($-2)
# C('function parameter')
-def p_term_index(p):
- 'termfunc : termvar OPENBRACKET expression CLOSEBRACKET'
+def p_term_parameter(p):
+ 'term : termvar OPENBRACKET expression CLOSEBRACKET'
if isarray(p[1]):
p[0] = '%s[%s-1]' % (p[1], p[3])
else:
@@ -573,10 +574,6 @@ def p_term_termfunc_parameter_parameter(p):
else:
p[0] = '%s(%s)' % (base, p[7])
-def p_term_termfunc(p):
- 'term : termfunc'
- p[0] = p[1]
-
# part(x,1:10)
def p_term_part_parameter_range(p):
'term : PART OPENBRACKET expression COMMA expression COLON expression CLOSEBRACKET'
@@ -681,12 +678,19 @@ def p_termvar_in(p):
'termvar : IN'
p[0] = '%s1' % (p[1])
+# 5
# 3.4
+# 4e5
+# 1.0d-4
+def p_term_number(p):
+ 'term : NUMBER'
+ number = re.sub(r'[de]', r'e', p[1], flags=re.IGNORECASE)
+ p[0] = '%s' % (number)
+
# 'abc'
# "abc"
-def p_term_constant(p):
- '''term : NUMBER
- | QSTRING
+def p_term_string(p):
+ '''term : QSTRING
| DQSTRING'''
p[0] = '%s' % (p[1])