[opengtl-commits] [262] report an error when there are too many arguments to a function

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 262
Author:   cyrille
Date:     2008-06-29 10:49:01 +0200 (Sun, 29 Jun 2008)

Log Message:
-----------
report an error when there are too many arguments to a function

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp


Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-06-29 08:48:30 UTC (rev 261)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-06-29 08:49:01 UTC (rev 262)
@@ -623,6 +623,10 @@
           if( isType( d->currentToken ) )
           {
             const Type* ptype = parseType();
+            if( not ptype )
+            {
+              return;
+            }
             if(isOfType( d->currentToken, Token::IDENTIFIER ) )
             {
               String pname = d->currentToken.string;
@@ -638,6 +642,7 @@
               } else if( needToHaveInitialiser )
               {
                 reportError( "Parameter need to have default initialiser once a parameter on the left had one.", d->currentToken );
+                return;
               }
               if( d->currentToken.type == Token::COMA or d->currentToken.type == Token::ENDBRACKET )
               {
@@ -1130,6 +1135,10 @@
     if( d->currentToken.type == Token::ENDBRACKET )
     {
       break;
+    } else if( arguments.size() == _parameters.size() ) {
+      // Too much arguments
+      reportError( "Too many arguments for function '" + _name + "'", d->currentToken);
+      return arguments;
     } else {
       int posArg = arguments.size();
       AST::Expression* expression = parseExpression( false, _parameters[ posArg ].type() );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/