Author: peterw
Date: 2006-07-19 03:16:38 -0400 (Wed, 19 Jul 2006)
New Revision: 62731

Added:
   trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser-rest.cs
Removed:
   trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs
Modified:
   trunk/mbuild/Monkeywrench.dll.sources
   trunk/mbuild/Monkeywrench/ChangeLog
Log:
2006-07-19  Peter Williams  <[EMAIL PROTECTED]>

        * Monkeywrench.Compiler/BuildfileParser-rest.cs: Renamed
        from BuildfileParserHelper.cs.



Modified: trunk/mbuild/Monkeywrench/ChangeLog
===================================================================
--- trunk/mbuild/Monkeywrench/ChangeLog 2006-07-19 07:12:32 UTC (rev 62730)
+++ trunk/mbuild/Monkeywrench/ChangeLog 2006-07-19 07:16:38 UTC (rev 62731)
@@ -1,5 +1,10 @@
 2006-07-19  Peter Williams  <[EMAIL PROTECTED]>
 
+       * Monkeywrench.Compiler/BuildfileParser-rest.cs: Renamed
+       from BuildfileParserHelper.cs.
+
+2006-07-19  Peter Williams  <[EMAIL PROTECTED]>
+
        * Monkeywrench.Compiler/BuildfileParser.jay: Move as much code as
        possible ...
 

Copied: trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser-rest.cs 
(from rev 62730, 
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs)

Deleted: 
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs    
2006-07-19 07:12:32 UTC (rev 62730)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs    
2006-07-19 07:16:38 UTC (rev 62731)
@@ -1,709 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using System.Text;
-
-using Mono.Build;
-using Mono.Build.Bundling;
-using Mono.Build.RuleLib;
-
-namespace Monkeywrench.Compiler {
-
-    public partial class BuildfileParser {
-
-       BuildfileTokenizer lexer;
-
-       string location_base;
-       string topsrc;
-       string resource_subdir;
-       ProviderBuilder pb;
-       IWarningLogger log;
-
-       NameLookupContext cur_nlc;
-
-       public BuildfileParser (StreamReader reader, string topsrc, string 
resource_subdir, 
-                               string location_base, ProviderBuilder pb, 
IWarningLogger log)
-       {
-           lexer = new BuildfileTokenizer (reader);
-
-           this.topsrc = topsrc;
-           this.resource_subdir = resource_subdir;
-           this.location_base = location_base;
-           this.pb = pb;
-           this.log = log;
-
-           cur_nlc = pb.NameContext;
-       }
-
-       public static BuildfileParser CreateForFile (string topsrc, string 
srcrel,
-                                                    ProviderBuilder pb, 
IWarningLogger log)
-       {
-           string file = Path.Combine (topsrc, srcrel);
-
-           FileStream fs = new FileStream (file, FileMode.Open, 
FileAccess.Read);
-           BufferedStream bs = new BufferedStream (fs);
-           StreamReader reader = new StreamReader (bs);
-
-           BuildfileParser p = new BuildfileParser (reader, topsrc, 
-                                                    Path.GetDirectoryName 
(srcrel), 
-                                                    file, pb, log);
-           p.AddResourceFile (Path.GetFileName (srcrel));
-
-           return p;
-       }
-
-       // Execution
-
-       static int yacc_verbose_flag = 1;
-
-       public static bool DebugParser = false;
-
-       public int Parse ()
-       {
-           try {
-               if (DebugParser)
-                   yyparse (lexer, new yydebug.yyDebugSimple ());
-               else
-                   yyparse (lexer);
-               lexer.Cleanup ();
-           } catch (yyParser.yyException yyex) {
-               Error (2038, "Parse error in build file", yyex.ToString ());
-           } catch (Exception e) {
-               Error (1001, "Exception while parsing build file.", e.ToString 
());
-           }
-           
-           return nerror;
-       }
-
-       // Misc
-
-       public BuildfileTokenizer Lexer {
-           get { return lexer; }
-       }  
-
-       // Helpers
-
-       class LinkList<T> {
-           public T item;
-           public LinkList<T> prev;
-
-           public LinkList (T item) : this (item, null) {}
-
-           public LinkList (T item, LinkList<T> prev) 
-           {
-               this.item = item;
-               this.prev = prev;
-           }
-
-           public LinkList<T> JoinPrev (LinkList<T> prev)
-           {
-               this.prev = prev;
-               return this;
-           }
-       }
-
-       // Weird errors occur when this is made a static 
-       // member of LinkList. But no biggie.
-
-       static LinkList<T> Reverse<T> (LinkList<T> l) 
-       {
-           // Algorithm copied from g_slist_reverse.
-           // Reverses in-place
-           
-           LinkList<T> prev = null;
-           
-           while (l != null) {
-               LinkList<T> next = l.prev;
-               l.prev = prev;
-               
-               prev = l;
-               l = next;
-           }
-           
-           return prev;
-       }
-
-       // Logging with location
-
-       string Location 
-       { 
-           get {
-               return location_base + ':' + lexer.LineNum.ToString ();
-           }
-       }
-
-       void Warning (int category, string text, string detail) 
-       {
-           log.PushLocation (Location);
-           log.Warning (category, text, detail);
-           log.PopLocation ();
-       }
-
-       void WarningV (int category, string fmt, params object[] items) 
-       {
-           Warning (category, String.Format (fmt, items), null);
-       }
-
-       int nerror = 0;
-
-       void Error (int category, string text, string detail) 
-       {
-           log.PushLocation (Location);
-           log.Error (category, text, detail);
-           log.PopLocation ();
-           nerror++;
-       }
-
-       void ErrorV (int category, string fmt, params object[] items) 
-       {
-           Error (category, String.Format (fmt, items), null);
-       }
-
-       // Resource files
-
-       int nresource = 0;
-
-       const string ResourceTarget = ".monkeywrench_resource_";
-
-       string AddResourceFile (string name) 
-       {
-           string srcrel = Path.Combine (resource_subdir, name);
-           string path = Path.Combine (topsrc, srcrel);
-
-           pb.Owner.AddDependentFile (srcrel, path);
-
-           string target = ResourceTarget + nresource.ToString ();
-           nresource++;
-
-           TargetBuilder tb = pb.DefineTarget (target);
-           tb.SetRuleType (typeof (SourcefileRule));
-           tb.Add (new MBString (name)); // override the name
-
-           return path;
-       }
-
-       // Response files
-
-       void LoadResponseFile (TargetBuilder tb, string arg, string file) 
-       {
-           string path = AddResourceFile (file);
-
-           using (Stream stream = File.OpenRead (path)) {
-               StreamReader reader = new StreamReader (stream);
-
-               string line;
-
-               while ((line = reader.ReadLine ()) != null) {
-                   // FIXME: enforce line chomping? ... sure!
-                   line = line.Trim ();
-
-                   if (line == "" || line[0] == '#')
-                       continue;
-
-                   if (arg != null)
-                       tb.Add (arg, line);
-                   else
-                       tb.Add (line);
-               }
-           }
-       }
-
-       // Using statements
-
-       void UseList (LinkList<string> names)
-       {
-           //Console.WriteLine ("Got using statement.");
-           // order of using statements shouldn't matter.
-
-           for (; names != null; names = names.prev) {
-               //Console.WriteLine ("Using {0}", iter.text);
-
-               if (cur_nlc.UseNamespace (names.item, log))
-                   // shouldn't happen -- cur_nlc doesn't have its
-                   // project set yet, so we can't check if all the namespace
-                   // references are actually valid.
-                   throw new Exception ("Unexpected early namespace error???");
-           }
-       }
-       
-       // Project Info
-
-       ProjectInfo pinfo;
-
-       public ProjectInfo PInfo { get { return pinfo; } }
-
-       void StartProjectInfo ()
-       {
-           if (pinfo != null)
-               ErrorV (9999, "Cannot have two project [] statements in a 
Buildfile");
-           else
-               pinfo = new ProjectInfo ();
-       }
-
-       void AddProjectProperty (string name, string val)
-       {
-           switch (name) {
-           case "name":
-               pinfo.Name = val;
-               break;
-           case "version":
-               pinfo.Version = val;
-               break;
-           case "compat-code":
-               pinfo.CompatCode = val;
-               break;
-           default:
-               WarningV (2004, "Unknown project property `{0}' (value: 
`{1}').", name, val);
-               break;
-           }
-       }
-
-       struct ANameItem {
-           public AssemblyName name;
-           public string target;
-
-           public ANameItem (AssemblyName name)
-           {
-               this.name = name;
-               this.target = null;
-           }
-
-           public void AddTo (ProjectInfo pinfo)
-           {
-               if (name != null)
-                   pinfo.AddRef (name);
-               else
-                   pinfo.AddPrivateRef (target);
-           }
-       }
-
-       void AddProjectReferences (LinkList<ANameItem> names)
-       {
-           for (; names != null; names = names.prev)
-               names.item.AddTo (pinfo);
-       }
-
-       // Inside statements
-
-       string[] where_inside;
-       NameLookupContext inside_nlc;
-
-       public string[] WhereInside { get { return where_inside; } }
-
-       public NameLookupContext InsideNameContext { get { return inside_nlc; } 
}
-
-       void StartInsideBases (LinkList<string> idents)
-       {
-           // FIXME: no reason this should be illegal
-           if (inside_nlc != null)
-               throw new Exception ("Cannot have two inside [] directives in 
one buildfile");
-
-           // oh god, the inefficiency. I forget why we sort here.
-
-           SortedList sl = new SortedList ();
-           for (; idents != null; idents = idents.prev) 
-               sl.Add (idents.item, idents.item);
-
-           where_inside = new string[sl.Count];
-
-           for (int i = 0; i < sl.Count; i++) {
-               string s = (string) sl.GetByIndex (i);
-
-               // normalize here to take load off code farther down line
-               // TODO: error check for other invalid forms
-               if (s[s.Length - 1] != '/')
-                   s = s + '/';
-
-               where_inside[i] = s;
-           }
-
-           inside_nlc = new NameLookupContext ();
-           cur_nlc = inside_nlc;
-       }
-
-       void FinishInside ()
-       {
-           cur_nlc = pb.NameContext;
-       }
-
-       // subdirs
-
-       List<string> subdirs = new List<string> ();
-
-       public IEnumerable<string> Subdirs { get { return subdirs; } }
-
-       void DoSubdirList (LinkList<string> idents)
-       {
-           for (; idents != null; idents = idents.prev) {
-               string dir = idents.item;
-
-               if (dir.IndexOfAny (Path.GetInvalidPathChars ()) != -1) {
-                   ErrorV (2002, "Item `{0}'in subdirs statement contains 
invalid " +
-                           "path characters.", dir);
-                   continue;
-               }
-
-               subdirs.Add (dir + "/");
-           }
-       }
-
-       // Loads
-
-       Dictionary<string,string> loads;
-
-       public IDictionary<string,string> ManualLoads { get { return loads; } }
-
-       void DoLoadStatement (string file, string basis)
-       {
-           if (basis[0] == '/') {
-               ErrorV (2011, "Basis `{0}' (declared in file `{1}') must be 
relative " +
-                       "to the declaring basis.", basis, file);
-               return;
-           }
-
-           if (loads == null)
-               loads = new Dictionary<string,string> ();
-
-           loads [basis + "/"] = file;
-       }
-
-       // Target definitions
-
-       void DefineTarget (string name, string rule_name, LinkList<DepItem> 
deps,
-                          LinkList<TagItem> tags)
-       {
-           if (CheckTargetName (name))
-               return;
-
-           TargetBuilder tb = pb.DefineTarget (name);
-           tb.RuleName = rule_name; // may be null
-
-           for (; deps != null; deps = deps.prev)
-               deps.item.AddTo (tb, this);
-
-           for (; tags != null; tags = tags.prev)
-               tags.item.AddTo (tb);
-       }
-
-       public static readonly char[] IllegalTargetChars = new char[] { '+', 
':', '/' };
-
-       bool CheckTargetName (string name) 
-       {
-           if (name[0] == '.') {
-               ErrorV (2003, "User-defined target name `{0}' may not start 
with a period", name);
-               return true;
-           }
-
-           int idx = name.IndexOfAny (IllegalTargetChars);
-
-           if (idx != -1) {
-               ErrorV (2008, "User-defined target name '{0}' may not contain 
the character `{1}'.",
-                       name, name[idx]);
-               return true;
-           }
-
-           if (!pb.CanDefineTarget (name)) {
-               ErrorV (2009, "Target `{0}' already defined.", name);
-               return true;
-           }
-           
-           return false;
-       }
-
-       class DepItem {
-           public object item;
-           public bool is_response;
-           public string arg;
-
-           public DepItem (object item) 
-           {
-               this.item = item;
-           }
-           
-           public DepItem (string arg, object item) 
-           {
-               this.arg = arg;
-               this.item = item;
-           }
-
-           public DepItem (string item, bool is_response) 
-           {
-               this.item = item;
-               this.is_response = is_response;
-           }
-
-           public void AddTo (TargetBuilder tb, BuildfileParser bp)
-           {
-               //Console.WriteLine ("dep: {0}, {1}, {2}", dep.arg, dep.name, 
dep.is_response);
-           
-               if (is_response) {
-                   if (!(item is string))
-                       throw ExHelp.App ("Don't know how to load {0} as a 
response file", item);
-
-                   bp.LoadResponseFile (tb, arg, (string) item);
-                   return;
-               }
-           
-               if (item is Result) {
-                   if (arg != null)
-                       tb.Add (arg, (Result) item);
-                   else
-                       tb.Add ((Result) item);
-                   return;
-               }
-
-               if (item is string) {
-                   if (arg != null)
-                       tb.Add (arg, (string) item);
-                   else
-                       tb.Add ((string) item);
-                   return;
-               }
-
-               if (item is LinkList<DepItem>) {
-                   // ordered dependency list
-
-                   LinkList<DepItem> iter = (LinkList<DepItem>) item;
-                   iter = Reverse<DepItem> (iter);
-
-                   for (; iter != null; iter = iter.prev) {
-                       DepItem subdep = iter.item;
-                       object subitem = subdep.item;
-
-                       if (subitem is Result) {
-                           if (arg != null)
-                               tb.Add (arg, (Result) subitem);
-                           else
-                               tb.AddDefaultOrdered ((Result) subitem);
-                       } else if (subitem is string) {
-                           if (arg != null)
-                               tb.Add (arg, (string) subitem);
-                           else
-                               tb.AddDefaultOrdered ((string) subitem);
-                       }
-                   }
-
-                   return;
-               }
-               
-               // This is just crazy text because there's no way to give a 
helpful
-               // message to a casual user.
-               throw new Exception ("parse error 52: " + item.ToString ());
-           }
-       }
-       
-       struct TagItem {
-           public string name;
-           public object val;
-
-           public TagItem (string name, object val)
-           {
-               this.name = name;
-               this.val = val;
-           }
-
-           public void AddTo (TargetBuilder tb)
-           {
-               if (val is string)
-                   tb.AddTargetTag (name, (string) val);
-               else
-                   tb.AddResultTag (name, (Result) val);
-           }
-       }
-
-       // Dictionaries
-
-       TargetBuilder cur_targ = null;
-
-       void FinishCurTagged (LinkList<TagItem> tags)
-       {
-           for (; tags != null; tags = tags.prev)
-               tags.item.AddTo (cur_targ);
-
-           cur_targ = null;
-       }
-
-       void StartDictionary (string name)
-       {
-           // we'll exit right after parse, doesn't matter
-           // if the target is still defined.
-
-           if (CheckTargetName (name))
-               return;
-
-           cur_targ = pb.DefineTarget (name);
-           cur_targ.SetRuleType (typeof (MakeDictionaryRule));
-       }
-
-       void AddDictionaryTarget (string key, string targ)
-       {
-           cur_targ.Add ("keys", new MBString (key));
-           cur_targ.Add ("vals", targ);
-       }
-
-       void AddDictionaryResult (string key, Result val)
-       {
-           cur_targ.Add ("keys", new MBString (key));
-           cur_targ.Add ("vals", val);
-       }
-
-       void FinishDictionary (LinkList<TagItem> tags)
-       {
-           FinishCurTagged (tags);
-       }
-
-       // Boolean expression helping
-
-       void DefineBoolOpsTarget (string name, BoolOps ops, LinkList<TagItem> 
tags)
-       {
-           if (CheckTargetName (name))
-               return;
-
-           cur_targ = pb.DefineTarget (name);
-
-           ops.DecodeInto (cur_targ);
-
-           FinishCurTagged (tags);
-       }
-
-       enum OpCode {
-           Not = -1,
-           And = -2,
-           Or = -3
-       }
-
-       class BoolOps {
-           public int[] commands;
-           public string[] targets;
-
-           private BoolOps () {}
-
-           public BoolOps (string targ) 
-           {
-               commands = new int[1] { 0 };
-               targets = new string[1] { targ };
-           }
-
-           public BoolOps (OpCode unary_op, string targ) 
-           {
-               if (unary_op != OpCode.Not)
-                   throw new InvalidOperationException ();
-
-               commands = new int[2] { 0, (int) unary_op };
-               targets = new string[1] { targ };
-           }
-
-           public BoolOps CombineUnary (OpCode unary_op)
-           {
-               if (unary_op != OpCode.Not)
-                   throw new InvalidOperationException ();
-
-               BoolOps res = new BoolOps ();
-               res.targets = targets;
-
-               res.commands = new int[commands.Length + 1];
-               commands.CopyTo (res.commands, 0);
-               res.commands[commands.Length] = (int) unary_op;
-
-               return res;
-           }
-
-           public BoolOps CombineBinary (OpCode op, BoolOps right)
-           {
-               if (op == OpCode.Not)
-                   throw new InvalidOperationException ();
-
-               Hashtable targmap = new Hashtable ();
-               ArrayList targlist = new ArrayList ();
-               int targindex = 0;
-               int lclen = commands.Length, rclen = right.commands.Length;
-               BoolOps res = new BoolOps ();
-
-               int idx = 0;
-               res.commands = new int[lclen + rclen + 1];
-
-               for (int i = 0; i < lclen; i++) {
-                   if (commands[i] < 0) {
-                       res.commands[idx++] = commands[i];
-                       continue;
-                   }
-
-                   string targ = targets[commands[i]];
-
-                   if (targmap.Contains (targ))
-                       res.commands[idx++] = (int) targmap[targ];
-                   else {
-                       targmap[targ] = targindex;
-                       targlist.Add (targ);
-                       res.commands[idx++] = targindex++;
-                   }
-               }
-               
-               for (int i = 0; i < rclen; i++) {
-                   if (right.commands[i] < 0) {
-                       res.commands[idx++] = right.commands[i];
-                       continue;
-                   }
-                   
-                   string targ = right.targets[right.commands[i]];
-                   
-                   if (targmap.Contains (targ))
-                       res.commands[idx++] = (int) targmap[targ];
-                   else {
-                       targmap[targ] = targindex;
-                       targlist.Add (targ);
-                       res.commands[idx++] = targindex++;
-                   }
-               }
-               
-               res.commands[idx] = (int) op;
-               
-               res.targets = new string[targlist.Count];
-               targlist.CopyTo (res.targets);
-               
-               return res;
-           }
-
-           public void DecodeInto (TargetBuilder tb)
-           {
-               // This limitation is only because I am lazy and want one 
character
-               // per BooleanHelper command.
-
-               if (targets.Length > 10)
-                   throw new InvalidOperationException ("Limited to 10 or 
fewer boolean operands");
-
-               tb.RuleName = "Core.BooleanHelper";
-
-               for (int i = 0; i < targets.Length; i++) 
-                   tb.AddDefaultOrdered (targets[i]);
-
-               StringBuilder sb = new StringBuilder ();
-
-               for (int i = 0; i < commands.Length; i++) {
-                   switch (commands[i]) {
-                   case (int) OpCode.Not: sb.Append ('!'); break;
-                   case (int) OpCode.And: sb.Append ('&'); break;
-                   case (int) OpCode.Or: sb.Append ('|'); break;
-                   case 0: sb.Append ('0'); break;
-                   case 1: sb.Append ('1'); break;
-                   case 2: sb.Append ('2'); break;
-                   case 3: sb.Append ('3'); break;
-                   case 4: sb.Append ('4'); break;
-                   case 5: sb.Append ('5'); break;
-                   case 6: sb.Append ('6'); break;
-                   case 7: sb.Append ('7'); break;
-                   case 8: sb.Append ('8'); break;
-                   case 9: sb.Append ('9'); break;
-                   default:
-                       throw new ArgumentException ("Don't know how to handle 
boolean ops command " +
-                                                    commands[i].ToString ());
-                   }
-               }
-
-               tb.Add (new MBString (sb.ToString ()));
-           }
-       }
-    }
-}

Modified: trunk/mbuild/Monkeywrench.dll.sources
===================================================================
--- trunk/mbuild/Monkeywrench.dll.sources       2006-07-19 07:12:32 UTC (rev 
62730)
+++ trunk/mbuild/Monkeywrench.dll.sources       2006-07-19 07:16:38 UTC (rev 
62731)
@@ -22,7 +22,7 @@
 Monkeywrench/Monkeywrench.Compiler/BinaryHelper.cs
 Monkeywrench/Monkeywrench.Compiler/BinaryLoadedGraph.cs
 Monkeywrench/Monkeywrench.Compiler/BuildfileParser.cs
-Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs
+Monkeywrench/Monkeywrench.Compiler/BuildfileParser-rest.cs
 Monkeywrench/Monkeywrench.Compiler/BuildfileProviderLoader.cs
 Monkeywrench/Monkeywrench.Compiler/BuildfileTokenizer.cs
 Monkeywrench/Monkeywrench.Compiler/DependentItemInfo.cs

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to