diff options
author | siddhu8990 | 2017-04-19 14:57:49 +0530 |
---|---|---|
committer | siddhu8990 | 2017-04-19 14:57:49 +0530 |
commit | b9cfdca438347fe4d28f7caff3cb7b382e455d3a (patch) | |
tree | 948593b7d89741f804919a74f2e5e34b39adb0a0 /2.3-1/macros/ASTManagement | |
parent | 586db6343e7b472d8dc3e63a82f4c73f99cdcbd7 (diff) | |
download | Scilab2C-b9cfdca438347fe4d28f7caff3cb7b382e455d3a.tar.gz Scilab2C-b9cfdca438347fe4d28f7caff3cb7b382e455d3a.tar.bz2 Scilab2C-b9cfdca438347fe4d28f7caff3cb7b382e455d3a.zip |
Merged Shamik's work
Diffstat (limited to '2.3-1/macros/ASTManagement')
24 files changed, 193 insertions, 0 deletions
diff --git a/2.3-1/macros/ASTManagement/_comment_string.bin b/2.3-1/macros/ASTManagement/_comment_string.bin Binary files differnew file mode 100644 index 00000000..fb894945 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_comment_string.bin diff --git a/2.3-1/macros/ASTManagement/_comment_string.sci b/2.3-1/macros/ASTManagement/_comment_string.sci new file mode 100644 index 00000000..a963507d --- /dev/null +++ b/2.3-1/macros/ASTManagement/_comment_string.sci @@ -0,0 +1,7 @@ +function txt=%comment_string(e) +//overloading function for "comment" type tlist string function +//fields: +// text: a string +//this is a leaf of the AST + txt=['Comment : '+e.text] +endfunction diff --git a/2.3-1/macros/ASTManagement/_cste_string.bin b/2.3-1/macros/ASTManagement/_cste_string.bin Binary files differnew file mode 100644 index 00000000..ba643c47 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_cste_string.bin diff --git a/2.3-1/macros/ASTManagement/_cste_string.sci b/2.3-1/macros/ASTManagement/_cste_string.sci new file mode 100644 index 00000000..ba9971d2 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_cste_string.sci @@ -0,0 +1,26 @@ +function txt=%cste_string(c) +//overloading function for "cste" type tlist string function +//this is a leaf of the AST +//fields: +// value : a number or a string +//NUT: added cste I also need "" for strings in order to be sure that the blanks are +//NUT: correctly considered and not mistaken with additional blanks present in the ast text file. + stringcvalue = string(c.value); + if (stringcvalue == "%T" | ... + stringcvalue == "%t" | ... + stringcvalue == "%F" | ... + stringcvalue == "%f" | ... + stringcvalue == "%nan" | ... + stringcvalue == "%inf" | ... + stringcvalue == "%e" | ... + stringcvalue == "%pi") + txt=['Number_x: '+stringcvalue]; + elseif (isnum(stringcvalue)) + //NUT needed to convert format 1D-14 into 1d-14 + txt=['Number_x: '+strsubst(stringcvalue,'D','e')]; + elseif (stringcvalue == "%i") + txt=['Number_X: '+stringcvalue]; + else + txt=['String: ""'+stringcvalue+'""']; + end +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/_equal_string.bin b/2.3-1/macros/ASTManagement/_equal_string.bin Binary files differnew file mode 100644 index 00000000..7f88fee6 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_equal_string.bin diff --git a/2.3-1/macros/ASTManagement/_equal_string.sci b/2.3-1/macros/ASTManagement/_equal_string.sci new file mode 100644 index 00000000..9678f0e0 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_equal_string.sci @@ -0,0 +1,16 @@ +function txt=%equal_string(e) +//overloading function for "equal" type tlist string function +//this is a node of the AST + +//fields: +// expression: "expression" type tlist (the right hand side) +// lhs : list of "variable" type tlist and "operation" type tlist // (the assignment) +// endsymbol : string (the orginal end-of-instruction symbol (, ; <CR>)) + txt=['Equal' + ' Expression: ' + ' '+string(e.expression) + ' Lhs : ' + ' '+objectlist2string(e.lhs) + 'EndEqual' + ] +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/_for_string.bin b/2.3-1/macros/ASTManagement/_for_string.bin Binary files differnew file mode 100644 index 00000000..c3fda16b --- /dev/null +++ b/2.3-1/macros/ASTManagement/_for_string.bin diff --git a/2.3-1/macros/ASTManagement/_for_string.sci b/2.3-1/macros/ASTManagement/_for_string.sci new file mode 100644 index 00000000..0ed9ca28 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_for_string.sci @@ -0,0 +1,15 @@ +function txt=%for_string(F) +//overloading function for "for" type tlist string function +//this is a node of the AST +//fields: +// expression : "expression" type tlist (the loop expression) +// statements : list of "equal" type tlist and list('EOL') (the +// for instructions list) +//NUT: raf cambiato ForExpression e ForStatements + txt=['For' + ' ForExpression:' + ' '+string(F.expression) + ' ForStatements:' + ' '+objectlist2string(F.statements) + 'EndFor'] +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/_funcall_string.bin b/2.3-1/macros/ASTManagement/_funcall_string.bin Binary files differnew file mode 100644 index 00000000..8354586d --- /dev/null +++ b/2.3-1/macros/ASTManagement/_funcall_string.bin diff --git a/2.3-1/macros/ASTManagement/_funcall_string.sci b/2.3-1/macros/ASTManagement/_funcall_string.sci new file mode 100644 index 00000000..faeb81d9 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_funcall_string.sci @@ -0,0 +1,15 @@ +function txt=%funcall_string(F) +//overloading function for "funcall" type tlist string function +//this is a node of the AST +//fields: +// rhs : a list +// name : string, the name of the function +// lhsnb: number, the number of function lhs + +txt=['Funcall : '+F.name + ' #lhs : '+string(F.lhsnb) + ' Rhs : ' + ' '+objectlist2string(F.rhs) + 'EndFuncall' + ] +endfunction diff --git a/2.3-1/macros/ASTManagement/_ifthenel_string.bin b/2.3-1/macros/ASTManagement/_ifthenel_string.bin Binary files differnew file mode 100644 index 00000000..1c6fa73d --- /dev/null +++ b/2.3-1/macros/ASTManagement/_ifthenel_string.bin diff --git a/2.3-1/macros/ASTManagement/_ifthenel_string.sci b/2.3-1/macros/ASTManagement/_ifthenel_string.sci new file mode 100644 index 00000000..6787a87c --- /dev/null +++ b/2.3-1/macros/ASTManagement/_ifthenel_string.sci @@ -0,0 +1,27 @@ +function txt=%ifthenel_string(I) +//overloading function for "ifthenel" type tlist string function +//this is a node of the AST +//fields: +// expression : "expression" type tlist (the if expression) +// then : list of "equal" type tlist and list('EOL') (the +// then instructions list) +// elseifs : a list of tlists +// else : list of "equal" type tlist and list('EOL') (the +// else instructions list) + txt=['If ' + ' Expression:' + ' '+string(I.expression) + ' If Statements' + ' '+objectlist2string(I.then)] + for e=I.elseifs + txt=[txt; + ' Else If Expression' + ' '+string(e.expression) + ' Else If Statements' + ' '+objectlist2string(e.then)] + end + txt=[txt; + ' Else Statements' + ' '+objectlist2string(I.else) + 'EndIf'] +endfunction diff --git a/2.3-1/macros/ASTManagement/_operatio_string.bin b/2.3-1/macros/ASTManagement/_operatio_string.bin Binary files differnew file mode 100644 index 00000000..40abf6b2 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_operatio_string.bin diff --git a/2.3-1/macros/ASTManagement/_operatio_string.sci b/2.3-1/macros/ASTManagement/_operatio_string.sci new file mode 100644 index 00000000..8421a3f4 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_operatio_string.sci @@ -0,0 +1,13 @@ +function txt=%operatio_string(O) +//overloading function for "operation" type tlist string function +//this is a node of the AST +//fields: +// operands: a list +// operator: a string + txt=['Operation' + ' Operands:' + ' '+objectlist2string(O.operands) + ' Operator: '+O.operator + 'EndOperation' + ] +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/_program_p.bin b/2.3-1/macros/ASTManagement/_program_p.bin Binary files differnew file mode 100644 index 00000000..216a38b2 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_program_p.bin diff --git a/2.3-1/macros/ASTManagement/_program_p.sci b/2.3-1/macros/ASTManagement/_program_p.sci new file mode 100644 index 00000000..f45ed69a --- /dev/null +++ b/2.3-1/macros/ASTManagement/_program_p.sci @@ -0,0 +1,4 @@ +function %program_p(p) + //overloading function for "program" type tlist display + mprintf("%s\n",string(p)) +endfunction diff --git a/2.3-1/macros/ASTManagement/_program_string.bin b/2.3-1/macros/ASTManagement/_program_string.bin Binary files differnew file mode 100644 index 00000000..3a8fc95b --- /dev/null +++ b/2.3-1/macros/ASTManagement/_program_string.bin diff --git a/2.3-1/macros/ASTManagement/_program_string.sci b/2.3-1/macros/ASTManagement/_program_string.sci new file mode 100644 index 00000000..93486992 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_program_string.sci @@ -0,0 +1,19 @@ +function txt=%program_string(p) +//overloading function for "program" type tlist string function +//main (root) node of the Abstract Formal Tree +//fields: +// name : string (the function name) +// outputs : list of "variable" type tlist (the output arg names) +// inputs : list of "variable" type tlist (the intput arg names) +// statements: list of "equal" type tlist and list('EOL') (the +// instructions list) +// nblines : number (the number of lines in the scilab function) + txt=['Program' + 'Name : '+p.name + 'Outputs: '+strcat(objectlist2string(p.outputs),' ') + 'Inputs : '+strcat(objectlist2string(p.inputs),' ') + 'Statements ' + ' '+objectlist2string(p.statements) + 'EndProgram' + ] +endfunction diff --git a/2.3-1/macros/ASTManagement/_variable_string.bin b/2.3-1/macros/ASTManagement/_variable_string.bin Binary files differnew file mode 100644 index 00000000..f81fd6e0 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_variable_string.bin diff --git a/2.3-1/macros/ASTManagement/_variable_string.sci b/2.3-1/macros/ASTManagement/_variable_string.sci new file mode 100644 index 00000000..86507957 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_variable_string.sci @@ -0,0 +1,26 @@ +function txt=%variable_string(v) + global anscounter; //NUT: just to fix problem with ans variables. +//overloading function for "variable" type tlist string function +//fields: name +//this is a leaf of the AST +//NUT: changed here. For me %i is a number not a variable. + if (v.name == "%T" | ... + v.name == "%t" | ... + v.name == "%F"| ... + v.name == "%f"| ... + v.name == "%nan"| ... + v.name == "%inf"| ... + v.name == "%e" | ... + v.name == "%pi") + txt=['Number_x: '+v.name]; + elseif (v.name == "%i") + txt=['Number_X: '+v.name]; + else + if (v.name == 'ans') + anscounter = anscounter + 1; + txt=['Variable: '+v.name+string(anscounter)]; + else + txt=['Variable: '+v.name]; + end + end +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/_while_string.bin b/2.3-1/macros/ASTManagement/_while_string.bin Binary files differnew file mode 100644 index 00000000..142189c6 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_while_string.bin diff --git a/2.3-1/macros/ASTManagement/_while_string.sci b/2.3-1/macros/ASTManagement/_while_string.sci new file mode 100644 index 00000000..7d5e6223 --- /dev/null +++ b/2.3-1/macros/ASTManagement/_while_string.sci @@ -0,0 +1,14 @@ +function txt=%while_string(W) +//overloading function for "while" type tlist string function +//this is a node of the AST +//fields: +// expression : "expression" type tlist (the loop expression) +// statements : list of "equal" type tlist and list('EOL') (the +// while instructions list) + txt=['While' + ' WhileExpression:' + ' '+string(W.expression) + ' WhileStatements:' + ' '+objectlist2string(W.statements) + 'EndWhile'] +endfunction diff --git a/2.3-1/macros/ASTManagement/lib b/2.3-1/macros/ASTManagement/lib Binary files differindex 7f0e1d70..0ba95377 100644 --- a/2.3-1/macros/ASTManagement/lib +++ b/2.3-1/macros/ASTManagement/lib diff --git a/2.3-1/macros/ASTManagement/names b/2.3-1/macros/ASTManagement/names index 7f6d053d..43522229 100644 --- a/2.3-1/macros/ASTManagement/names +++ b/2.3-1/macros/ASTManagement/names @@ -41,4 +41,15 @@ AST_ReadEqualRhsNames GenOutArgNames Operator2FunName SciFile2ASTFile +_comment_string +_cste_string +_equal_string +_for_string +_funcall_string +_ifthenel_string +_operatio_string +_program_p +_program_string +_variable_string +_while_string objectlist2string |