summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--combined.js8
-rw-r--r--js/NonLinear/DLRADAPT_f.js2
-rw-r--r--js/NonLinear/EXPBLK_f.js2
-rw-r--r--js/NonLinear/EXPBLK_m.js2
-rw-r--r--js/NonLinear/LOGBLK_f.js2
-rwxr-xr-xsci2jslex.py1
-rwxr-xr-xsci2jsyacc.py31
7 files changed, 36 insertions, 12 deletions
diff --git a/combined.js b/combined.js
index 556107b0..eadbe93d 100644
--- a/combined.js
+++ b/combined.js
@@ -8600,7 +8600,7 @@ break
DLRADAPT_f.prototype.define = function DLRADAPT_f() {
p=[0,1];
rn=[];
-rd=[math.complex("0.2+0.8i"),math.complex("0.2-0.8i"),math.complex("0.3+0.7i"),math.complex("0.3-0.7i")];
+rd=[math.complex(0.2,0.8),math.complex(0.2,-0.8),math.complex(0.3,0.7),math.complex(0.3,-0.7)];
g=[1,1];
last_u=[];
last_y=[0,0];
@@ -8709,7 +8709,7 @@ break
}
LOGBLK_f.prototype.define = function LOGBLK_f() {
in1=1;
-a=%e;
+a=math.E;
model=scicos_model();
model.sim="logblk";
model.in=-1;
@@ -8799,7 +8799,7 @@ break
}
EXPBLK_m.prototype.define = function EXPBLK_m() {
in1=1;
-a=%e;
+a=math.E;
model=scicos_model();
model.sim=list("expblk_m",4);
model.in=-1;
@@ -9015,7 +9015,7 @@ break
}
EXPBLK_f.prototype.define = function EXPBLK_f() {
in1=1;
-a=%e;
+a=math.E;
model=scicos_model();
model.sim="expblk";
model.in=-1;
diff --git a/js/NonLinear/DLRADAPT_f.js b/js/NonLinear/DLRADAPT_f.js
index d79aea87..7eb57e9d 100644
--- a/js/NonLinear/DLRADAPT_f.js
+++ b/js/NonLinear/DLRADAPT_f.js
@@ -34,7 +34,7 @@ break
DLRADAPT_f.prototype.define = function DLRADAPT_f() {
p=[0,1];
rn=[];
-rd=[math.complex("0.2+0.8i"),math.complex("0.2-0.8i"),math.complex("0.3+0.7i"),math.complex("0.3-0.7i")];
+rd=[math.complex(0.2,0.8),math.complex(0.2,-0.8),math.complex(0.3,0.7),math.complex(0.3,-0.7)];
g=[1,1];
last_u=[];
last_y=[0,0];
diff --git a/js/NonLinear/EXPBLK_f.js b/js/NonLinear/EXPBLK_f.js
index 5c99a517..4952f704 100644
--- a/js/NonLinear/EXPBLK_f.js
+++ b/js/NonLinear/EXPBLK_f.js
@@ -28,7 +28,7 @@ break
}
EXPBLK_f.prototype.define = function EXPBLK_f() {
in1=1;
-a=%e;
+a=math.E;
model=scicos_model();
model.sim="expblk";
model.in=-1;
diff --git a/js/NonLinear/EXPBLK_m.js b/js/NonLinear/EXPBLK_m.js
index 5d548d31..531ca3fb 100644
--- a/js/NonLinear/EXPBLK_m.js
+++ b/js/NonLinear/EXPBLK_m.js
@@ -28,7 +28,7 @@ break
}
EXPBLK_m.prototype.define = function EXPBLK_m() {
in1=1;
-a=%e;
+a=math.E;
model=scicos_model();
model.sim=list("expblk_m",4);
model.in=-1;
diff --git a/js/NonLinear/LOGBLK_f.js b/js/NonLinear/LOGBLK_f.js
index 8b17f02e..26210f1e 100644
--- a/js/NonLinear/LOGBLK_f.js
+++ b/js/NonLinear/LOGBLK_f.js
@@ -30,7 +30,7 @@ break
}
LOGBLK_f.prototype.define = function LOGBLK_f() {
in1=1;
-a=%e;
+a=math.E;
model=scicos_model();
model.sim="logblk";
model.in=-1;
diff --git a/sci2jslex.py b/sci2jslex.py
index 74f0ef0d..473a44ba 100755
--- a/sci2jslex.py
+++ b/sci2jslex.py
@@ -48,6 +48,7 @@ syntaxtokens = {
predefinedvariables = {
'f': 'PREVAR_BOOLEAN',
+ 'e': 'PREVAR_FLOAT',
'i': 'PREVAR_COMPLEX',
'pi': 'PREVAR_FLOAT',
't': 'PREVAR_BOOLEAN',
diff --git a/sci2jsyacc.py b/sci2jsyacc.py
index 01b12200..f2f680bc 100755
--- a/sci2jsyacc.py
+++ b/sci2jsyacc.py
@@ -504,8 +504,7 @@ def p_term_lastindex(p):
# %f
def p_term_prevar(p):
- '''term : PREVAR
- | PREVAR_FLOAT'''
+ 'term : PREVAR'
p[0] = str(p[1])
# %f
@@ -517,9 +516,33 @@ def p_term_prevar_boolean(p):
p[0] == 'false'
# 1+2*%i
-def p_term_prevar_complex(p):
+def p_term_prevar_complex1(p):
'expression : expression ADDITION expression MULTIPLICATION PREVAR_COMPLEX'
- p[0] = 'math.complex("' + p[1] + p[2] + p[3] + 'i")'
+ if p[2] == '-':
+ imag = str(p[2]) + str(p[3])
+ else:
+ imag = str(p[3])
+ p[0] = 'math.complex(' + p[1] + ',' + imag + ')'
+
+# 1+2*%i
+def p_term_prevar_complex2(p):
+ 'expression : expression ADDITION PREVAR_COMPLEX MULTIPLICATION expression'
+ if p[2] == '-':
+ imag = str(p[2]) + str(p[5])
+ else:
+ imag = str(p[5])
+ p[0] = 'math.complex(' + p[1] + ',' + imag + ')'
+
+# %e %pi
+def p_term_prevar_float(p):
+ 'term : PREVAR_FLOAT'
+ if p[1] == '%e':
+ flt = 'math.E'
+ elif p[1] == '%pi':
+ flt = 'math.PI'
+ else:
+ flt = p[1]
+ p[0] = flt
def p_term_termvar(p):
'term : termvar'