Author: dda
Date: 2007-12-17 13:03:09 -0800 (Mon, 17 Dec 2007)
New Revision: 7569

Modified:
   
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
   
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
Log:
Change 20071217-dda-b by [EMAIL PROTECTED] on 2007-12-17 15:58:06 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog

Summary: Support ...rest syntax for variable args in SWF9.

New Features: varargs uses AS3 syntax.

Bugs Fixed: none

Technical Reviewer: ptw (pending)
QA Reviewer: hminsky (pending)
Doc Reviewer: (pending)

Documentation: none

Release Notes: none

Details:
    Recognize the '...' syntax for formal argument lists, and pass it through 
to SWF9 compiler.
    This does not do anything for other runtimes, I'll file a JIRA and cover 
that separately.

Tests:
    simple test to add ... to existing method and see it added on output.



Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
 2007-12-17 21:02:39 UTC (rev 7568)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
 2007-12-17 21:03:09 UTC (rev 7569)
@@ -268,6 +268,7 @@
 | < SEMICOLON: ";" >
 | < COMMA: "," >
 | < DOT: "." >
+| < ELLIPSIS: "..." >
 }
 
 /* operators */
@@ -878,9 +879,11 @@
    FormalParameter() ("," FormalParameter())*
 }
 
-void FormalParameter() #void : {ASTIdentifier id; ASTIdentifier.Type type;}
+void FormalParameter() #void : {boolean ellipsis = false; ASTIdentifier id; 
ASTIdentifier.Type type;}
 {
-    id = Identifier() [":" type = TypeIdentifier() { id.setType(type); }]
+    ["..." { ellipsis = true; }]
+    id = Identifier() { id.setEllipsis(ellipsis); }
+    [":" type = TypeIdentifier() { id.setType(type); }]
 }
 
 // Program structuring/

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
  2007-12-17 21:02:39 UTC (rev 7568)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
  2007-12-17 21:03:09 UTC (rev 7569)
@@ -13,6 +13,7 @@
     private String name = null;
     private Type type = null;
     private int hash = 0;
+    private boolean ellipsis = false;
 
     public static class Type {
         public String typeName = null;
@@ -71,12 +72,21 @@
         this.type = type;
     }
 
+    public boolean getEllipsis() {
+        return ellipsis;
+    }
+
+    public void setEllipsis(boolean ellipsis) {
+        this.ellipsis = ellipsis;
+    }
+
     public String toString() {
+        String dots = ellipsis ? "..." : "";
         String typesuffix = "";
         if (type != null) {
             typesuffix = ": " + type.toString();
         }
-        return "ASTIdentifier(" + name + typesuffix + ")";
+        return "ASTIdentifier(" + dots + name + typesuffix + ")";
     }
 
     /** Accept the visitor */

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
     2007-12-17 21:02:39 UTC (rev 7568)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
     2007-12-17 21:03:09 UTC (rev 7569)
@@ -140,5 +140,14 @@
   public String visitPragmaDirective(SimpleNode node, String[] children) {
     return "// (ignored) pragma " + children[0];
   }
+
+  public String visitIdentifier(SimpleNode node, String[] children) {
+    ASTIdentifier ident = (ASTIdentifier)node;
+    String name = ident.getName();
+    String type = ident.getType() == null ? "" : (":" + ident.getType());
+    String ellipsis = ident.getEllipsis() ? "..." : "";
+
+    return ellipsis + name + type;
+  }
 }
   


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to