[svn] r5871: nemerle/trunk: ncc/parsing/MainParser.n tools/nemerlish/eval.n

nazgul svnadmin at nemerle.org
Wed Nov 2 18:48:39 CET 2005


Log:
Update nemish to recent changes in Passes and MainParser

Author: nazgul
Date: Wed Nov  2 18:48:14 2005
New Revision: 5871

Modified:
   nemerle/trunk/ncc/parsing/MainParser.n
   nemerle/trunk/tools/nemerlish/eval.n

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Wed Nov  2 18:48:14 2005
@@ -28,6 +28,7 @@
  
 using Nemerle.Collections;
 using Nemerle.Compiler.Parsetree;
+using Nemerle.Assertions;
 
 namespace Nemerle.Compiler
 {
@@ -111,7 +112,7 @@
     /** Parse given string as expression, given context in which this
         expression is situated.
      */
-    public static ParseExpr (env : GlobalEnv, expr : string) : PExpr
+    public static ParseExpr ([NotNull] env : GlobalEnv, [NotNull] expr : string) : PExpr
     {
       // we must prevent lexer from bailing out on last token at end of input
       def lexer = LexerString (expr + " ", Location_stack.top ());
@@ -121,11 +122,12 @@
     /** Parse given string as expression, given context in which this
         expression is situated.
      */
-    public static ParseExpr (env : GlobalEnv, lexer : LexerBase) : PExpr
+    public static ParseExpr ([NotNull] env : GlobalEnv, [NotNull] lexer : LexerBase) : PExpr
     {
       def preparser = PreParser (lexer);
       def tokens = preparser.PreParse ();
       def parser = MainParser (env);
+
       if (tokens.Child.Next == null)
         parser.push_stream ((tokens.Child :> Token.LooseGroup).Child);
       else

Modified: nemerle/trunk/tools/nemerlish/eval.n
==============================================================================
--- nemerle/trunk/tools/nemerlish/eval.n	(original)
+++ nemerle/trunk/tools/nemerlish/eval.n	Wed Nov  2 18:48:14 2005
@@ -52,7 +52,6 @@
       Options.ProgressBar = false;
       Options.Sources = [""];
   
-      Passes.LexingPipeline = fun (_) { null };
       Passes.ParsingPipeline = fun (_) { [null] };
       Passes.ScanningPipeline = DoTheStuff;
 
@@ -83,6 +82,7 @@
     public Eval (code: string) : list [bool * bool * string * object * PExpr] {
       Evaluator.code = code;
 
+      Passes.LexingPipeline = fun (_) { null };
 //    Options.DumpTypedTree = true;
 //    Options.AdditionalDebug = true;
       
@@ -257,22 +257,24 @@
         | _ => ()
       }
       
-      // If the code ends with an assignment, append `()'.
-      // Put a call to stagedmacro at the end of the evaluated code
-      // with the last expression moved to the stagedmacro argument.
-      def whole = match (body) {
-        | <[ {..$seq } ]> => 
-          def (beg, last) = List.DivideLast (seq);
-          def last = 
-            match (last) {
+      def make_last (last) {
               | <[ def $_ = $_ ]> 
               | <[ mutable $_ = $_ ]> 
               | <[ def .. $_ ]> =>
                 <[ $last; $("stagedmacro" : usesite) (()) ]>
               | _ => <[ $("stagedmacro" : usesite) ($last) ]>
             }
+      
+      // If the code ends with an assignment, append `()'.
+      // Put a call to stagedmacro at the end of the evaluated code
+      // with the last expression moved to the stagedmacro argument.
+      def whole = match (body) {
+        | <[ {..$seq } ]> => 
+          def (beg, last) = List.DivideLast (seq);
+          def last = make_last (last);
           <[ {..$ (beg + [last]) } ]>
-        | _ => <[ $("stagedmacro" : usesite) ($body) ]>
+          
+        | _ => make_last (body)
       }
   
       // Recreate variables defined in previous calls to Eval.



More information about the svn mailing list