changeset 21:0fb2d13dce37

Now working with gdc also (gdc use reverse paremeter validating on function calls)
author johnsen@johnsen-laptop
date Fri, 18 Apr 2008 21:39:17 +0200
parents 95e3940d91d4
children e331e4e816e4 dd18654b5131
files lexer/Token.d parser/Parser.d test.td
diffstat 3 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lexer/Token.d	Fri Apr 18 20:28:49 2008 +0200
+++ b/lexer/Token.d	Fri Apr 18 21:39:17 2008 +0200
@@ -113,6 +113,7 @@
         Tok.Integer:"Integer",
         Tok.If:"If",
         Tok.While:"While",
+        Tok.Comma:"Comma",
         Tok.Return:"Return",
         Tok.Seperator:"Seperator"
     ];
--- a/parser/Parser.d	Fri Apr 18 20:28:49 2008 +0200
+++ b/parser/Parser.d	Fri Apr 18 21:39:17 2008 +0200
@@ -7,6 +7,8 @@
        ast.Stmt,
        ast.Decl;
 
+import misc.Error;
+
 import tango.io.Stdout,
        Integer = tango.text.convert.Integer;
 
@@ -45,6 +47,7 @@
                 Identifier type = new Identifier(t);
 
                 Token iden = lexer.next;
+
                 switch(iden.type)
                 {
                     case Tok.Identifier:
@@ -170,7 +173,9 @@
 
         while(lexer.peek.type != Tok.CloseParentheses)
         {
-            funcArgs ~= new VarDecl(parseType, parseIdentifier);
+            auto t = parseType;
+            auto i = parseIdentifier;
+            funcArgs ~= new VarDecl(t, i);
 
             if(lexer.peek.type == Tok.Comma)
                 lexer.next;
@@ -191,7 +196,7 @@
                 return new Identifier(identifier);
                 break;
             default:
-                error("Unexpexted token in Identifier parsing");
+                throw new Error("Unexpexted token in Identifier parsing. Got "~identifier.getType, identifier.location);
         }
     }
 
--- a/test.td	Fri Apr 18 20:28:49 2008 +0200
+++ b/test.td	Fri Apr 18 21:39:17 2008 +0200
@@ -16,8 +16,8 @@
 
 int nice(long s, short t)
 {
+    int y;
     byte x = 5 + t + y;
-    int y;
     if (x != 0)
         t = 5 + 1 * 5 * s + t;
     return 2 * (t + -1) - x;