summaryrefslogtreecommitdiff
path: root/README
blob: 25fe96603b0a650fd9905c847b09cedacb31655b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Project:

convert from .sci files in scilab blocks modules to .js files for use with xcos
on cloud.

Requirements:

python      2.7.12
python-ply  3.7
make        4.1

Running:

There are two files for modification:

1. sci2jslex.py

This contains the tokenizer for the input .sci files. The file is read and
divided into tokens. Each token will give the token type and the corresponding
value. The token types are used in describing the grammar rules of the files.
The token values are used in the python code to replace the input with the
required output. Here are a few sample token types from the input .sci files:

a.

EOL

Meaning: end-of-line

Matching text:

new-line, in some cases semi-colon and comma, also an entire comment block like this:

//  Scicos
//
//  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>

Special notes:

In some cases, new lines are parsed differently. For example, if there is an
opening bracket '(' or '[' on a line, and no matching close bracket ']' or ')',
then the new line is treated as space.

b.

SPACE

Meaning: space

Matching text:

any string of multiple spaces and tabs

Special note:

In some cases, the space token is not significant. In that case, it does not generate a token. Instead, it is just parsed and skipped.

c. 

BREAK CASE DO ELSE ELSEIF END ENDFUNCTION FOR FUNCTION IF SELECT THEN WHILE

Meaning: part of language syntax. They are used in the conditionals, loops, and function definitions

Matching text:

corresponding language tokens

d.

IN

Meaning: a variable name

Matching text:

in

Special note:

'in' is a reserved word in javascript, whereas it is used as a normal variable
in scilab. Hence, it is treated specially to replace 'in' with 'in1' in
javascript.

e.

PREVAR PREVAR_BOOLEAN PREVAR_COMPLEX PREVAR_FLOAT

Meaning: a predefined variable

Matching text:

'%' followed by a word. Example: %e %f %i %pi %t

any word which starts with % is treated a predefined variable. each variable can be used in specific context only.

Special note:

Only some of the predefined variables are known.
%t and %f are boolean values representing true and false in javascript respectively.
%e and %pi are float values representing math.E and math.PI in javascript respectively.
%i is an imaginary value representing math.complex(0, 1).
Work is pending for other predefined variables.

f.

VAR

Meaning: a variable

Matching text:

any alphabet followed by series of alphanumeric characters. _ is considered as an alphabet.

Example:

A _out rpar N ymin win