[svn] r6426: nemerle/trunk/ncc: testsuite/positive/macrolib.n
typing/Macros.n
nazgul
svnadmin at nemerle.org
Tue Jul 4 21:34:38 CEST 2006
Log:
Improve quotation handling
Author: nazgul
Date: Tue Jul 4 21:34:35 2006
New Revision: 6426
Modified:
nemerle/trunk/ncc/testsuite/positive/macrolib.n
nemerle/trunk/ncc/typing/Macros.n
Modified: nemerle/trunk/ncc/testsuite/positive/macrolib.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/macrolib.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/macrolib.n Tue Jul 4 21:34:35 2006
@@ -21,8 +21,9 @@
macro generateIFoo ()
{
+ def ifaces = [<[ IFoo ]> ];
def tb = Nemerle.Macros.ImplicitCTX ().Env.Define (<[ decl:
- public class BlahBle : IFoo
+ public class BlahBle : ..$ifaces
{
public Foo () : void
{
Modified: nemerle/trunk/ncc/typing/Macros.n
==============================================================================
--- nemerle/trunk/ncc/typing/Macros.n (original)
+++ nemerle/trunk/ncc/typing/Macros.n Tue Jul 4 21:34:35 2006
@@ -378,6 +378,12 @@
| _ => Lift (members, quoted_member);
}
+ private lift_with_ellipsis (exprs : list [PExpr]) : PExpr
+ {
+ | [Ellipsis (e)] => quoted_expr (e)
+ | _ => Lift (exprs, quoted_expr);
+ }
+
internal quoted_tydecl (td : TopDeclaration) : PExpr {
def qn = quoted_sstring (td.name);
def qattr = quoted_attributes (td.modifiers);
@@ -385,7 +391,7 @@
match (td) {
| TopDeclaration.Class ( t_extends = extend, decls = members) =>
- def qexten = Lift (extend, quoted_expr);
+ def qexten = lift_with_ellipsis (extend);
def qmems = lift_members (members);
<[ TopDeclaration.Class (name = $qn, modifiers = $qattr, t_extends = $qexten,
@@ -395,14 +401,14 @@
<[ TopDeclaration.Alias (name = $qn, modifiers = $qattr, typarms = $qtparms, ty = $(quoted_expr (t))) ]>
| TopDeclaration.Interface (t_extends = extend, methods = members) =>
- def qexten = Lift (extend, quoted_expr);
+ def qexten = lift_with_ellipsis (extend);
def qmems = lift_members (members);
<[ TopDeclaration.Interface (name = $qn, modifiers = $qattr, t_extends = $qexten,
typarms = $qtparms, methods = $qmems) ]>
| TopDeclaration.Variant (t_extends = extend, decls = members) =>
- def qexten = Lift (extend, quoted_expr);
+ def qexten = lift_with_ellipsis (extend);
def qmems = lift_members (members);
<[ TopDeclaration.Variant (name = $qn, modifiers = $qattr, t_extends = $qexten,
@@ -414,7 +420,7 @@
<[ TopDeclaration.VariantOption (name = $qn, modifiers = $qattr, typarms = $qtparms, decls = $qmems) ]>
| TopDeclaration.Enum (t_extends = extend, decls = members) =>
- def qexten = Lift (extend, quoted_expr);
+ def qexten = lift_with_ellipsis (extend);
def qmems = lift_members (members);
<[ TopDeclaration.Enum (name = $qn, modifiers = $qattr, t_extends = $qexten,
@@ -552,20 +558,10 @@
<[ PExpr.Member ($(quoted_expr (obj)), $(quoted_sstring (mem))) ]>
| <[ $func (.. $parms) ]> =>
- match (parms) {
- | [ PExpr.Ellipsis (args) ] =>
- <[ PExpr.Call ($(quoted_expr (func)), $(quoted_expr (args))) ]>
- | _ =>
- <[ PExpr.Call ($(quoted_expr (func)), $(Lift (parms, quoted_expr))) ]>
- }
+ <[ PExpr.Call ($(quoted_expr (func)), $(lift_with_ellipsis (parms))) ]>
| <[ $func .[..$parms] ]> =>
- match (parms) {
- | [ PExpr.Ellipsis (args) ] =>
- <[ PExpr.GenericSpecifier ($(quoted_expr (func)), $(quoted_expr (args))) ]>
- | _ =>
- <[ PExpr.GenericSpecifier ($(quoted_expr (func)), $(Lift (parms, quoted_expr))) ]>
- }
+ <[ PExpr.GenericSpecifier ($(quoted_expr (func)), $(lift_with_ellipsis (parms))) ]>
| <[ $target = $source ]> =>
<[ PExpr.Assign ($(quoted_expr (target)), $(quoted_expr (source))) ]>
@@ -645,39 +641,19 @@
<[ PExpr.TypeConversion ($(quoted_expr (expr)), $(quoted_expr (ty))) ]>
| <[ {.. $seq } ]> =>
- match (seq) {
- | [PExpr.Ellipsis (seq)] =>
- <[ PExpr.Sequence ($(quoted_expr (seq))) ]>
- | _ =>
- <[ PExpr.Sequence ($(Lift (seq, quoted_expr))) ]>
- }
+ <[ PExpr.Sequence ($(lift_with_ellipsis (seq))) ]>
| <[ (.. $args) ]> =>
- match (args) {
- | [PExpr.Ellipsis (args)] =>
- <[ PExpr.Tuple ($(quoted_expr (args))) ]>
- | _ =>
- <[ PExpr.Tuple ($(Lift (args, quoted_expr))) ]>
- }
+ <[ PExpr.Tuple ($(lift_with_ellipsis (args))) ]>
| <[ array .[ $rank ] $value ]> =>
<[ PExpr.Array ($(quoted_expr (rank)), $(quoted_expr (value))) ]>
| <[ array (.. $sizes) ]> =>
- match (sizes) {
- | [PExpr.Ellipsis (args)] =>
- <[ PExpr.EmptyArray ($(quoted_expr (args))) ]>
- | _ =>
- <[ PExpr.EmptyArray ($(Lift (sizes, quoted_expr))) ]>
- }
+ <[ PExpr.EmptyArray ($(lift_with_ellipsis (sizes))) ]>
| <[ $obj [.. $args] ]> =>
- match (args) {
- | [PExpr.Ellipsis (args)] =>
- <[ PExpr.Indexer ($(quoted_expr (obj)), $(quoted_expr (args))) ]>
- | _ =>
- <[ PExpr.Indexer ($(quoted_expr (obj)), $(Lift (args, quoted_expr))) ]>
- }
+ <[ PExpr.Indexer ($(quoted_expr (obj)), $(lift_with_ellipsis (args))) ]>
| <[ _ ]> => <[ PExpr.Wildcard () ]>
@@ -693,12 +669,7 @@
<[ PExpr.Where ($(quoted_expr (e1)), $(quoted_expr (e2))) ]>
| PExpr.ListLiteral (elems) =>
- match (elems) {
- | [PExpr.Ellipsis (args)] =>
- <[ PExpr.ListLiteral ($(quoted_expr (args))) ]>
- | _ =>
- <[ PExpr.ListLiteral ($(Lift (elems, quoted_expr))) ]>
- }
+ <[ PExpr.ListLiteral ($(lift_with_ellipsis (elems))) ]>
// rest of constructs must be in not quoted form, because they define
// internal data structures
More information about the svn
mailing list