Author: dda
Date: 2007-12-07 12:04:42 -0800 (Fri, 07 Dec 2007)
New Revision: 7483

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
   openlaszlo/trunk/test/typevar.lzx
Log:
Change 20071206-dda-9 by [EMAIL PROTECTED] on 2007-12-06 17:36:12 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/trunk-b
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fixes for [not] nullable syntax, and return type syntax for function.

New Features: none

Bugs Fixed: LPP-5059

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

Documentation: none

Release Notes: none - feature is not yet released or used.

Details:
    The grammar fix for nullable is straightforward.

    For function return values, given that functions
    can be declared with/or without an identifier (using function expressions),
    we cannot put the type information on an ASTIdentifier, since
    there may not be one.  The logical place to put the return value
    is on the FormalParameterList, which might now be thought of as
    the function's signature (if it weren't rather disruptive,
    I would have changed the name).  Any function whether created
    as a declaration or expression, has a FormalParamterList, so it
    is a convenient place in the grammar.  Making this change
    actually cleaned up the grammar slightly, I think.

Tests:
1)   Run test/typevar.lzx to check nullable syntax, should give no errors.

2)   Run lzsc on:

// tests for return types

function f1() { }
function f2() : void { }
function f3():Integer? { }
function f4():Integer! { }
function f5(x):Integer! { }
function f6(x:int):Integer! { }
function f7(x:int,y):Integer! { }
function f8(x,y:int):Integer! { }
function f9(x:int,y:int):Integer! { }
function f10(x:int?,y:int):Integer! { }
function f11(x:int?,y:int!):Integer! { }
var x = function (x:int?,y:int!):Integer! { }

   Running lzsc is currently the only way to test this, that will probably 
change soon.

3)   Compared binary LFC files from compiler to make sure no regressions.

4)   Ran smokecheck.lzx to make sure no regressions.




Modified: 
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt     
2007-12-07 18:50:19 UTC (rev 7482)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt     
2007-12-07 20:04:42 UTC (rev 7483)
@@ -669,14 +669,23 @@
   }
 }
 
+ASTIdentifier.Type TypeIdentifierOrVoid() #void : { ASTIdentifier.Type type = 
null; }
+{
+  (
+    "void" {type = null;}
+  | type = TypeIdentifier()
+  ) {
+    return type;
+  }
+}
+
 ASTIdentifier.Type TypeIdentifier() #void : { Token t; ASTIdentifier.Type type 
= new ASTIdentifier.Type(); }
 {
   (
-    Nullable() {type.nullable = true; }
-    t = <IDENTIFIER> {type.typeName = t.image;}
-  |
-    t = <IDENTIFIER> {type.typeName = t.image;}
-    [NotNullable() {type.notnullable = true; }]
+    t = <IDENTIFIER>    {type.typeName = t.image;}
+      [ NotNullable()   {type.notnullable = true; }
+      | Nullable()      {type.nullable = true; }
+      ]
   ) {
     return type;
   }
@@ -842,25 +851,33 @@
 
 // Function declaration
 
-void FunctionDeclaration() #FunctionDeclaration : {ASTIdentifier id; 
ASTIdentifier.Type type;}
+void FunctionDeclaration() #FunctionDeclaration : {ASTFormalParameterList 
formals; ASTIdentifier.Type type;}
 {
-    "function" id = Identifier() 
-    [":" type = TypeIdentifier() { id.setType(type); }]
-    ("(" [FormalParameterList()] ")") 
#FormalParameterList(jjtree.nodeArity()==0)
+    "function" Identifier()
+    formals = FormalParameterList()
+    [":" type = TypeIdentifierOrVoid() { formals.setReturnType(type); }]
     Block()
 }
 
-void FunctionExpression() #FunctionExpression : {}
+void FunctionExpression() #FunctionExpression : {ASTFormalParameterList 
formals; ASTIdentifier.Type type;}
 {
-    "function" (Identifier())?  ("(" [FormalParameterList()] ")") 
#FormalParameterList(jjtree.nodeArity()==0) Block()
+    "function" (Identifier())?
+    formals = FormalParameterList()
+    [":" type = TypeIdentifierOrVoid() { formals.setReturnType(type); }]
+    Block()
 }
 
-SimpleNode FormalParameterList() #FormalParameterList : {Token t;}
+ASTFormalParameterList FormalParameterList() #FormalParameterList : {}
 {
-   FormalParameter() ("," FormalParameter())*
+     "(" [FormalParameters()] ")" 
      { return jjtThis; }
 }
 
+void FormalParameters() : {}
+{
+   FormalParameter() ("," FormalParameter())*
+}
+
 void FormalParameter() #void : {ASTIdentifier id; ASTIdentifier.Type type;}
 {
     id = Identifier() [":" type = TypeIdentifier() { id.setType(type); }]

Modified: openlaszlo/trunk/test/typevar.lzx
===================================================================
--- openlaszlo/trunk/test/typevar.lzx   2007-12-07 18:50:19 UTC (rev 7482)
+++ openlaszlo/trunk/test/typevar.lzx   2007-12-07 20:04:42 UTC (rev 7483)
@@ -14,7 +14,7 @@
       var v_init_const = 4;
       var v_typed:int;
       var v_typed_init:int = val * 2;
-      var v_typed_q:?int = 123;
+      var v_typed_q:int? = 123;
       var v_typed_ex:int! = 234;
 
       // These must be set before use


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

Reply via email to