[svn] r7662: nemerle/trunk/ncc/parsing/MainParser.n
VladD2
svnadmin at nemerle.org
Wed May 9 09:14:43 CEST 2007
Log:
1. Add support auto-property (like in C# 3.0). At now you can define property as following: "public MyProp : int { get; private set; }"
2. Fix location of embedded (in property) field.
3. Add overload for ParseExpr().
Author: VladD2
Date: Wed May 9 09:14:41 2007
New Revision: 7662
Modified:
nemerle/trunk/ncc/parsing/MainParser.n
Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n (original)
+++ nemerle/trunk/ncc/parsing/MainParser.n Wed May 9 09:14:41 2007
@@ -121,8 +121,16 @@
[NotNull] expr : string,
allow_empty = false) : PExpr
{
+ ParseExpr (env, expr, Location_stack.top (), allow_empty);
+ }
+
+ public static ParseExpr ([NotNull] env : GlobalEnv,
+ [NotNull] expr : string,
+ startLocation : Location,
+ allow_empty = false) : PExpr
+ {
// we must prevent lexer from bailing out on last token at end of input
- def lexer = LexerString (env.Manager, expr + " ", Location_stack.top ());
+ def lexer = LexerString (env.Manager, expr + " ", startLocation);
ParseExpr (env, lexer, allow_empty)
}
@@ -1050,7 +1058,7 @@
System.AttributeTargets.Field, true, attrs);
def embed = PExpr.Quoted (SyntaxElement.ClassMember (
- ClassMember.Field (loc + t.Location, nm, attrs, t)));
+ ClassMember.Field (nametok.Location + t.Location, nm, attrs, t)));
mods.AddCustomAttribute (<[
$(mkname ("Nemerle") : name).InternalMacros.PropertyEmbeddedField ($embed)
]>);
@@ -1062,6 +1070,24 @@
pop_stream ("property member");
}
+ // Support autoproperty (see C# 3.0 specification).
+ when (!(mods.Attributes %&& (NemerleAttributes.Abstract | NemerleAttributes.Extern)) && parms.IsEmpty)
+ match (getter, setter)
+ {
+ | (Some(ClassMember.Function(_, _, FunBody.Abstract) as getr),
+ Some(ClassMember.Function(_, _, FunBody.Abstract) as setr)) =>
+
+ def embed = PExpr.Quoted (SyntaxElement.ClassMember (
+ <[ decl: mutable field : $ret_type; ]>));
+ mods.AddCustomAttribute (<[ $(mkname ("Nemerle") : name).InternalMacros.PropertyEmbeddedField ($embed) ]>);
+
+ getr.Body = <[ field ]>;
+ setr.Body = <[ field = value ]>;
+
+ | _ => ()
+ }
+
+
def prop = ClassMember.Property (loc + group.Location, id, mods,
ret_type, prop_ty, parms, getter, setter);
More information about the svn
mailing list