[Swift-commit] r2315 - in trunk: resources tests/language-behaviour

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Wed Oct 22 12:28:05 CDT 2008


Author: benc
Date: 2008-10-22 12:28:04 -0500 (Wed, 22 Oct 2008)
New Revision: 2315

Added:
   trunk/tests/language-behaviour/0011-echo.out.expected
   trunk/tests/language-behaviour/0011-echo.swift
Modified:
   trunk/resources/swiftscript.g
Log:
alternative app block syntax

Modified: trunk/resources/swiftscript.g
===================================================================
--- trunk/resources/swiftscript.g	2008-10-22 07:03:23 UTC (rev 2314)
+++ trunk/resources/swiftscript.g	2008-10-22 17:28:04 UTC (rev 2315)
@@ -174,6 +174,7 @@
 
 // this is a declaration, but not sorted out the predications yet to
 // group it into a decl block
+    | ("app") => d=appproceduredecl {code.setAttribute("functions",d);}
     | (predictProceduredecl) => d=proceduredecl {code.setAttribute("functions", d);}
     ;
 
@@ -371,6 +372,49 @@
         }
     ;
 
+appproceduredecl returns [StringTemplate code=template("function")]
+{StringTemplate f=null;
+ StringTemplate app=template("app");
+ StringTemplate exec=null; }
+    :   "app"
+        ( LPAREN
+        f=formalParameter
+        {
+        f.setAttribute("outlink", "true");
+        code.setAttribute("outputs", f);
+        }
+        (   COMMA f=formalParameter
+            {
+            f.setAttribute("outlink", "true");
+            code.setAttribute("outputs", f);
+            }
+        )*
+        RPAREN )?
+        id:ID {currentFunctionName=id.getText();} LPAREN
+        (   f=formalParameter
+            {
+            code.setAttribute("inputs", f);
+            }
+            (   COMMA f=formalParameter
+                {
+                code.setAttribute("inputs", f);
+                }
+            )*
+        )?
+        RPAREN
+        LCURLY
+        exec=declarator
+        {app.setAttribute("exec",exec);}
+        ( appArg[app] )* SEMI
+        {code.setAttribute("config",app);}
+        RCURLY
+        {
+        code.setAttribute("name", id.getText());
+        currentFunctionName=null;
+        }
+    ;
+
+
 // TODO in here, why do we have an | between LBRACKBRACK and ASSIGN?
 // does this mean that we don't have array initialisation in formal
 // params? this wouldn't surprise me given the previous treatment

Added: trunk/tests/language-behaviour/0011-echo.out.expected
===================================================================
--- trunk/tests/language-behaviour/0011-echo.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/0011-echo.out.expected	2008-10-22 17:28:04 UTC (rev 2315)
@@ -0,0 +1 @@
+hello

Added: trunk/tests/language-behaviour/0011-echo.swift
===================================================================
--- trunk/tests/language-behaviour/0011-echo.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/0011-echo.swift	2008-10-22 17:28:04 UTC (rev 2315)
@@ -0,0 +1,10 @@
+type messagefile;
+
+app (messagefile t) greeting() { 
+        echo "hello" stdout=@filename(t);
+}
+
+messagefile outfile <"0011-echo.out">;
+
+outfile = greeting();
+




More information about the Swift-commit mailing list