summaryrefslogtreecommitdiff
path: root/2.3-1/macros/ASTManagement/SciFile2ASTFile.sci
diff options
context:
space:
mode:
authorSandeep Gupta2017-06-18 23:55:40 +0530
committerSandeep Gupta2017-06-18 23:55:40 +0530
commitb43eccd4cffed5bd1017c5821524fb6e49202f78 (patch)
tree4c53d798252cbeae9bcf7dc9604524b20bb10f27 /2.3-1/macros/ASTManagement/SciFile2ASTFile.sci
downloadScilab2C-b43eccd4cffed5bd1017c5821524fb6e49202f78.tar.gz
Scilab2C-b43eccd4cffed5bd1017c5821524fb6e49202f78.tar.bz2
Scilab2C-b43eccd4cffed5bd1017c5821524fb6e49202f78.zip
First commit
Diffstat (limited to '2.3-1/macros/ASTManagement/SciFile2ASTFile.sci')
-rw-r--r--2.3-1/macros/ASTManagement/SciFile2ASTFile.sci36
1 files changed, 36 insertions, 0 deletions
diff --git a/2.3-1/macros/ASTManagement/SciFile2ASTFile.sci b/2.3-1/macros/ASTManagement/SciFile2ASTFile.sci
new file mode 100644
index 00000000..be978c57
--- /dev/null
+++ b/2.3-1/macros/ASTManagement/SciFile2ASTFile.sci
@@ -0,0 +1,36 @@
+function SciFile2ASTFile(SciFile,ASTFile);
+// function SciFile2ASTFile(SciFile,ASTFile);
+// -----------------------------------------------------------------
+// This function makes use of the macr2tree function to generate
+// the ASTFile containing the AST (Abstract Syntactic Tree) of the
+// input Scilab function (SciFile).
+//
+// Input data:
+// SciFile: full path of the input function.
+// ASTFile: full path of the file that will store the AST.
+//
+// Output data:
+// ---
+//
+// Status:
+// 12-Apr-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+exec(SciFile);
+[tmppath,ScilabFunName,tmpext] = fileparts(SciFile);
+AST=eval('macr2tree('+ScilabFunName+')');
+
+
+[ASTx,ASTierr]=fileinfo(ASTFile);
+if ASTierr == 0
+ mdelete(ASTFile);
+end
+
+fd = mopen(ASTFile, "wt");
+mputl(string(AST), fd);
+mclose(fd);
+
+endfunction