diff options
author | Jorawar Singh | 2017-06-30 11:54:22 +0530 |
---|---|---|
committer | Jorawar Singh | 2017-06-30 11:54:22 +0530 |
commit | a7d283ae2899b2530ac70a2453d4db05d03d609d (patch) | |
tree | fb93a9edddeee4601c47ce73e173331fa3addac8 /macros/ASTManagement/AST_HandleWhileStatem.sci | |
parent | aef4e8398f2b1848b0e4cdd9580dbbe93e4006f9 (diff) | |
parent | bee6bf6e37f6c36fb18b6132702e1528b7edafc2 (diff) | |
download | Scilab2C_fossee_old-a7d283ae2899b2530ac70a2453d4db05d03d609d.tar.gz Scilab2C_fossee_old-a7d283ae2899b2530ac70a2453d4db05d03d609d.tar.bz2 Scilab2C_fossee_old-a7d283ae2899b2530ac70a2453d4db05d03d609d.zip |
merged main repo with local
Diffstat (limited to 'macros/ASTManagement/AST_HandleWhileStatem.sci')
-rw-r--r-- | macros/ASTManagement/AST_HandleWhileStatem.sci | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/macros/ASTManagement/AST_HandleWhileStatem.sci b/macros/ASTManagement/AST_HandleWhileStatem.sci index 79fb516..d8c2f73 100644 --- a/macros/ASTManagement/AST_HandleWhileStatem.sci +++ b/macros/ASTManagement/AST_HandleWhileStatem.sci @@ -36,6 +36,8 @@ global SCI2CSTACK global StackPosition; global STACKDEDUG +IfCondArg = []; +NIfCondArg = 0; // ------------------------------ // --- Check input arguments. --- @@ -70,36 +72,40 @@ PrintStringInfo(' Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPa // --- Generate C code. --- // ------------------------ //#RNU_RES_E -if(SharedInfo.WhileExpr.CondVar == '') - //#RNU_RES_B - // It means that we are handling something like while(a) or while(1) - // The while condition variable is generated by the HandleEndGenFun. - //#RNU_RES_E - - // --- Pop the name of the condition variable or number. --- - Pop1 = AST_PopASTStack(); - - [ArgName,ArgScope] = AST_ExtractNameAndScope(Pop1); - if (length(ArgName) == 0) - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Expected while(variable) or while(number).','','stdout','y'); - PrintStringInfo('SCI2CERROR: Expected a variable or number in the AST while expression.','','stdout','y'); - PrintStringInfo('SCI2CERROR: Report this error to http://forge.scilab.org/index.php/p/scilab2c/issues/.','','stdout','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - error(9999, 'Expected a conditional variable in the while expression'); +flagendpop = 0; +IfExprField = AST_PopASTStack(); + +NOp=0; +Op=[]; +while (flagendpop == 0) + if (IfExprField~='<EOL>') + if (IfExprField=='WhileExpression:') + flagendpop = 1; + // Pop Again the If tag from the AST. + IfExprField = AST_PopASTStack(); + elseif (IfExprField=='Operands:') + flagendpop = 0; + g = AST_PopASTStack(); + else + if (IfExprField=='&&' | IfExprField=='||') + NOp = NOp + 1; + Op(NOp) = IfExprField; + //PrintStringInfo('operators are '+Op(NOp),ReportFileName,'file','y'); + else + NIfCondArg = NIfCondArg + 1; + IfCondArg(NIfCondArg) = IfExprField; + end + //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); + //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); + end end + IfExprField = AST_PopASTStack(); + PrintStringInfo('operators are '+IfExprField,ReportFileName,'file','y'); +end - SharedInfo.WhileExpr.CondVar = ArgName; - //#RNU_RES_B - // --- Repush strings into the AST stack. --- - //#RNU_RES_E - - AST_PushASTStack(Pop1); +IfCondArg = SCI2Cflipud(IfCondArg); -elseif (SharedInfo.WhileExpr.DimCondVar > 0) - error(9999, 'Cannot manage while with matrix conditions'); -end -SharedInfo = C_WhileExpression(FileInfo,SharedInfo); +SharedInfo = C_WhileExpression(IfCondArg,NIfCondArg,Op,NOp,FileInfo,SharedInfo); // -------------------------- // --- Update SharedInfo. --- |