Author: peterw
Date: 2006-07-19 23:08:35 -0400 (Wed, 19 Jul 2006)
New Revision: 62789

Modified:
   trunk/mbuild/Buildfile
   trunk/mbuild/ChangeLog
   trunk/mbuild/Languages.CrappyC.bundle
   trunk/mbuild/MBuildDynamic.Core/ChangeLog
   trunk/mbuild/MBuildDynamic.Core/Core.bundle
   trunk/mbuild/Monkeywrench/ChangeLog
   trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser-rest.cs
   trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser.jay
   trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileProviderLoader.cs
   trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileTokenizer.cs
   trunk/mbuild/Tools.PkgConfig.bundle
   trunk/mbuild/test/ChangeLog
   trunk/mbuild/test/mb-graphstat.cs
Log:
Improve the Buildfile parser a lot. This checkin introduces grammar changes
which affect the mbuild Buildfiles; to migrate, build and install the version
associated with this checkin, then update to the next checkin, then rebuild and
reinstall.

Monkeywrench:

2006-07-19  Peter Williams  <[EMAIL PROTECTED]>

        * Monkeywrench.Compiler/BuildfileParser.jay: Rework the grammar to
        handle centralize the loading of things with values, that is, targets
        or literal results. We add to this set 'constructed results', which
        are built with implicitly-defined targets. These include dictionaries
        and boolean operations, which we had hackishly before, but add on 
        formatted strings ("a{0}b{1}" % [a, b]) and conditionals (a ? b : c).
        The new grammar is much more flexible, allowing dictionaries to be
        defined inside target definitions and recursive constructed target
        definitions. For example,

        foo = Clone [ 
           { field = "string1", another = "test{0}" % [ mono-pcprobe ? "yes" : 
"no" ] } 
        ]

        We need to make a tiny tweak: ordered arguments are now surrounded
        with [], not {}.
        
        * Monkeywrench.Compiler/BuildfileParser-rest.cs: Rearrange code to
        support the above.

2006-07-19  Peter Williams  <[EMAIL PROTECTED]>

        * Monkeywrench.Compiler/BuildfileParser-rest.cs (AddSubdir): 
        Add subdirectories progressively, instead of building a list of
        them.
        (AddUnversionedReference): Same for bundle references.
        (StartInside): Similar for 'inside' statements, make more flexible.
        Can now have multiple inside statements per buildfile.
        (UseNamespace): More delisting.

        * Monkeywrench.Compiler/BuildfileParser.jay: Grammar changes 
        reflecting the above.

        * Monkeywrench.Compiler/BuildfileProviderLoader.cs (Initialize): 
        Track the more flexible inside API.

MBuildDynamic.Core:

2006-07-19  Peter Williams  <[EMAIL PROTECTED]>

        * Core.bundle (FormatHelper): Rename from format; shouldn't really be
        invoked explicitly since we have the nice syntax for it now.

test:

2006-07-19  Peter Williams  <[EMAIL PROTECTED]>

        * mb-graphstat.cs: Print out the results in the result table, because
        ... why not?

topsrcdir:

2006-07-19  Peter Williams  <[EMAIL PROTECTED]>

        * Languages.CrappyC.bundle (DefAddQuotes): Remove now that we can format
        strings nicely.

        * Tools.PkgConfig.bundle (PkgConfigProbe): Fix an important inverted 
logic
        bug introduced in the invasive changes.



Modified: trunk/mbuild/Buildfile
===================================================================
--- trunk/mbuild/Buildfile      2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/Buildfile      2006-07-20 03:08:35 UTC (rev 62789)
@@ -278,10 +278,10 @@
 # run MBuild from the build directory it finds the wrapper.
 # Note pkglibdir_installer, not bindir_installer.
 
-mb-install-client = Subst [ scripts/tmpl.in scripts/ic_map ] with [
-       install = /config/install/pkglibdir_installer 
-       default = true
-]
+#mb-install-client = Subst [ scripts/tmpl.in scripts/ic_map ] with [
+#      install = /config/install/pkglibdir_installer 
+#      default = true
+#]
 
 # for now, this is how we do our version of EXTRA_DIST
 
@@ -299,4 +299,3 @@
        with [ install = /config/mbuild/doc_installer ]
 NEWS = TextSource[] 
        with [ install = /config/mbuild/doc_installer ]
-

Modified: trunk/mbuild/ChangeLog
===================================================================
--- trunk/mbuild/ChangeLog      2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/ChangeLog      2006-07-20 03:08:35 UTC (rev 62789)
@@ -1,3 +1,14 @@
+2006-07-19  Peter Williams  <[EMAIL PROTECTED]>
+
+       * Buildfile.config (docdir): Change the syntax of the default ordered
+       argument to match the new one.
+
+       * Languages.CrappyC.bundle (DefAddQuotes): Remove now that we can format
+       strings nicely.
+
+       * Tools.PkgConfig.bundle (PkgConfigProbe): Fix an important inverted 
logic
+       bug introduced in the invasive changes.
+
 2006-07-18  Peter Williams  <[EMAIL PROTECTED]>
 
        * *.bundle: Remove 'field' keywords.

Modified: trunk/mbuild/Languages.CrappyC.bundle
===================================================================
--- trunk/mbuild/Languages.CrappyC.bundle       2006-07-20 02:40:33 UTC (rev 
62788)
+++ trunk/mbuild/Languages.CrappyC.bundle       2006-07-20 03:08:35 UTC (rev 
62789)
@@ -463,18 +463,6 @@
                @}
        }
 
-       rule DefAddQuotes {
-               # Little utility for string definitions in cflags. Might as 
well go here.
-               # FIXME: should be superseded by a nice string.format syntax in 
Buildfiles.
-
-               string instr;
-
-               build (MBString res, ctxt) @{
-                       res.Value = String.Format ("\"{0}\"", instr);
-                       return false;
-               @}
-       }
-
        # Linker options - need to think about this. C-specific?
 
        # Actual compiling

Modified: trunk/mbuild/MBuildDynamic.Core/ChangeLog
===================================================================
--- trunk/mbuild/MBuildDynamic.Core/ChangeLog   2006-07-20 02:40:33 UTC (rev 
62788)
+++ trunk/mbuild/MBuildDynamic.Core/ChangeLog   2006-07-20 03:08:35 UTC (rev 
62789)
@@ -1,3 +1,8 @@
+2006-07-19  Peter Williams  <[EMAIL PROTECTED]>
+
+       * Core.bundle (FormatHelper): Rename from format; shouldn't really be
+       invoked explicitly since we have the nice syntax for it now.
+
 2006-07-18  Peter Williams  <[EMAIL PROTECTED]>
 
        * *.bundle: Remove 'field' keywords.

Modified: trunk/mbuild/MBuildDynamic.Core/Core.bundle
===================================================================
--- trunk/mbuild/MBuildDynamic.Core/Core.bundle 2006-07-20 02:40:33 UTC (rev 
62788)
+++ trunk/mbuild/MBuildDynamic.Core/Core.bundle 2006-07-20 03:08:35 UTC (rev 
62789)
@@ -179,7 +179,7 @@
                @}
        }
 
-       rule Format {
+       rule FormatHelper {
                default string format;
                default ordered string* values;
 

Modified: trunk/mbuild/Monkeywrench/ChangeLog
===================================================================
--- trunk/mbuild/Monkeywrench/ChangeLog 2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/Monkeywrench/ChangeLog 2006-07-20 03:08:35 UTC (rev 62789)
@@ -1,8 +1,46 @@
 2006-07-19  Peter Williams  <[EMAIL PROTECTED]>
 
+       * Monkeywrench.Compiler/BuildfileParser.jay: Rework the grammar to
+       handle centralize the loading of things with values, that is, targets
+       or literal results. We add to this set 'constructed results', which
+       are built with implicitly-defined targets. These include dictionaries
+       and boolean operations, which we had hackishly before, but add on 
+       formatted strings ("a{0}b{1}" % [a, b]) and conditionals (a ? b : c).
+       The new grammar is much more flexible, allowing dictionaries to be
+       defined inside target definitions and recursive constructed target
+       definitions. For example,
+
+       foo = Clone [ 
+          { field = "string1", another = "test{0}" % [ mono-pcprobe ? "yes" : 
"no" ] } 
+       ]
+
+       We need to make a tiny tweak: ordered arguments are now surrounded
+       with [], not {}.
+       
+       * Monkeywrench.Compiler/BuildfileParser-rest.cs: Rearrange code to
+       support the above.
+
+2006-07-19  Peter Williams  <[EMAIL PROTECTED]>
+
+       * Monkeywrench.Compiler/BuildfileParser-rest.cs (AddSubdir): 
+       Add subdirectories progressively, instead of building a list of
+       them.
+       (AddUnversionedReference): Same for bundle references.
+       (StartInside): Similar for 'inside' statements, make more flexible.
+       Can now have multiple inside statements per buildfile.
+       (UseNamespace): More delisting.
+
+       * Monkeywrench.Compiler/BuildfileParser.jay: Grammar changes 
+       reflecting the above.
+
+       * Monkeywrench.Compiler/BuildfileProviderLoader.cs (Initialize): 
+       Track the more flexible inside API.
+
+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

Modified: 
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser-rest.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser-rest.cs     
2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser-rest.cs     
2006-07-20 03:08:35 UTC (rev 62789)
@@ -125,6 +125,14 @@
            return prev;
        }
 
+       static string CanonicalizeBasis (string basis)
+       {
+           if (basis[basis.Length - 1] == '/')
+               return basis;
+
+           return basis + '/';
+       }
+
        // Logging with location
 
        string Location 
@@ -212,20 +220,13 @@
 
        // Using statements
 
-       void UseList (LinkList<string> names)
+       void UseNamespace (string name)
        {
-           //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???");
-           }
+           if (cur_nlc.UseNamespace (name, 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
@@ -260,67 +261,55 @@
            }
        }
 
-       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 AddUnversionedReference (string name)
+       {
+           pinfo.AddRef (BundleManager.MakeName (name));
        }
 
-       void AddProjectReferences (LinkList<ANameItem> names)
+       void AddVersionedReference (string name, string vers)
        {
-           for (; names != null; names = names.prev)
-               names.item.AddTo (pinfo);
+           pinfo.AddRef (BundleManager.MakeName (name, vers));
        }
 
        // Inside statements
 
-       string[] where_inside;
-       NameLookupContext inside_nlc;
+       public class InsideInfo {
+           List<string> bases;
+           NameLookupContext nlc;
 
-       public string[] WhereInside { get { return where_inside; } }
+           public InsideInfo ()
+           {
+               nlc = new NameLookupContext ();
+               bases = new List<string> ();
+           }
 
-       public NameLookupContext InsideNameContext { get { return inside_nlc; } 
}
+           public IEnumerable<string> Bases { get { return bases; } }
 
-       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");
+           public NameLookupContext Context { get { return nlc; } }
 
-           // oh god, the inefficiency. I forget why we sort here.
+           public void Add (string basis)
+           {
+               bases.Add (BuildfileParser.CanonicalizeBasis (basis));
+           }
+       }
 
-           SortedList sl = new SortedList ();
-           for (; idents != null; idents = idents.prev) 
-               sl.Add (idents.item, idents.item);
+       List<InsideInfo> insides = new List<InsideInfo> ();
 
-           where_inside = new string[sl.Count];
+       public IEnumerable<InsideInfo> Insides { get { return insides; } }
 
-           for (int i = 0; i < sl.Count; i++) {
-               string s = (string) sl.GetByIndex (i);
+       InsideInfo cur_inside;
 
-               // normalize here to take load off code farther down line
-               // TODO: error check for other invalid forms
-               if (s[s.Length - 1] != '/')
-                   s = s + '/';
+       void StartInside ()
+       {
+           cur_inside = new InsideInfo ();
+           insides.Add (cur_inside);
 
-               where_inside[i] = s;
-           }
+           cur_nlc = cur_inside.Context;
+       }
 
-           inside_nlc = new NameLookupContext ();
-           cur_nlc = inside_nlc;
+       void AddInsideBasis (string basis)
+       {
+           cur_inside.Add (basis);
        }
 
        void FinishInside ()
@@ -334,19 +323,15 @@
 
        public IEnumerable<string> Subdirs { get { return subdirs; } }
 
-       void DoSubdirList (LinkList<string> idents)
+       void AddSubdir (string dir)
        {
-           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);
+               return;
+           }
 
-               if (dir.IndexOfAny (Path.GetInvalidPathChars ()) != -1) {
-                   ErrorV (2002, "Item `{0}'in subdirs statement contains 
invalid " +
-                           "path characters.", dir);
-                   continue;
-               }
-
-               subdirs.Add (dir + "/");
-           }
+           subdirs.Add (CanonicalizeBasis (dir));
        }
 
        // Loads
@@ -371,22 +356,110 @@
 
        // Target definitions
 
-       void DefineTarget (string name, string rule_name, LinkList<DepItem> 
deps,
-                          LinkList<TagItem> tags)
+       TargetBuilder cur_targ = null;
+
+       void StartTarget (string name)
        {
            if (CheckTargetName (name))
                return;
 
-           TargetBuilder tb = pb.DefineTarget (name);
-           tb.RuleName = rule_name; // may be null
+           cur_targ = pb.DefineTarget (name);
+           cur_arg_name = null;
+       }
 
-           for (; deps != null; deps = deps.prev)
-               deps.item.AddTo (tb, this);
+       void FinishTarget ()
+       {
+           cur_targ = null;
+           cur_arg_name = null;
+       }
 
-           for (; tags != null; tags = tags.prev)
-               tags.item.AddTo (tb);
+       void SetTargetRuleName (string rule_name)
+       {
+           cur_targ.RuleName = rule_name;
        }
 
+       string cur_arg_name;
+
+       struct SingleValue {
+           string target;
+           Result result;
+
+           public SingleValue (string t)
+           {
+               target = t;
+               result = null;
+           }
+
+           public SingleValue (Result r)
+           {
+               target = null;
+               result = r;
+           }
+
+           public void AddAsDep (string arg, TargetBuilder tb)
+           {
+               if (arg == null) {
+                   if (target == null)
+                       tb.Add (result);
+                   else
+                       tb.Add (target);
+               } else {
+                   if (target == null)
+                       tb.Add (arg, result);
+                   else
+                       tb.Add (arg, target);
+               }
+           }
+
+           public void AddAsDefaultOrdered (TargetBuilder tb)
+           {
+               if (target == null)
+                   tb.AddDefaultOrdered (result);
+               else
+                   tb.AddDefaultOrdered (target);
+           }
+
+           public void AddAsTag (string tag, TargetBuilder tb)
+           {
+               if (target == null)
+                   tb.AddResultTag (tag, result);
+               else
+                   tb.AddTargetTag (tag, target);
+           }
+
+           public void AddAsDictItem (string key, TargetBuilder tb)
+           {
+               tb.Add ("keys", new MBString (key));
+
+               if (target == null)
+                   tb.Add ("vals", result);
+               else
+                   tb.Add ("vals", target);
+           }
+       }
+
+       void ApplyOrderedDeps (LinkList<SingleValue> list)
+       {
+           list = Reverse<SingleValue> (list);
+
+           if (cur_arg_name == null)
+               for (; list != null; list = list.prev)
+                   list.item.AddAsDefaultOrdered (cur_targ);
+           else
+               for (; list != null; list = list.prev)
+                   list.item.AddAsDep (cur_arg_name, cur_targ);
+       }
+
+       void AddTargetTag (string name, SingleValue val)
+       {
+           val.AddAsTag (name, cur_targ);
+       }
+           
+       void AddResponseDependencies (string responsefile)
+       {
+           LoadResponseFile (cur_targ, cur_arg_name, responsefile);
+       }
+
        public static readonly char[] IllegalTargetChars = new char[] { '+', 
':', '/' };
 
        bool CheckTargetName (string name) 
@@ -412,160 +485,63 @@
            return false;
        }
 
-       class DepItem {
-           public object item;
-           public bool is_response;
-           public string arg;
+       void SetTargetAsValue (SingleValue val)
+       {
+           cur_targ.SetRuleType (typeof (CloneRule));
+           val.AddAsDep (cur_arg_name, cur_targ);
+       }
 
-           public DepItem (object item) 
-           {
-               this.item = item;
-           }
-           
-           public DepItem (string arg, object item) 
-           {
-               this.arg = arg;
-               this.item = item;
-           }
+       // Constructed targets
 
-           public DepItem (string item, bool is_response) 
-           {
-               this.item = item;
-               this.is_response = is_response;
-           }
+       int nconstructed = 0;
 
-           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);
+       class ConstructedInfo {
+           public TargetBuilder tb;
+           public ConstructedInfo parent;
 
-                   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;
-               }
+           const string ConstructedTarget = ".implicit_";
 
-               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)
+           public ConstructedInfo (ConstructedInfo parent, BuildfileParser bp)
            {
-               this.name = name;
-               this.val = val;
+               this.parent = parent;
+               this.tb = bp.pb.DefineTarget (ConstructedTarget + 
bp.nconstructed++);
            }
-
-           public void AddTo (TargetBuilder tb)
-           {
-               if (val is string)
-                   tb.AddTargetTag (name, (string) val);
-               else
-                   tb.AddResultTag (name, (Result) val);
-           }
        }
 
-       // Dictionaries
+       ConstructedInfo cur_constructed = null;
 
-       TargetBuilder cur_targ = null;
-
-       void FinishCurTagged (LinkList<TagItem> tags)
+       void StartConstructed ()
        {
-           for (; tags != null; tags = tags.prev)
-               tags.item.AddTo (cur_targ);
-
-           cur_targ = null;
+           cur_constructed = new ConstructedInfo (cur_constructed, this);
        }
 
-       void StartDictionary (string name)
+       void FinishConstructed ()
        {
-           // 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));
+           cur_constructed = cur_constructed.parent;
        }
 
-       void AddDictionaryTarget (string key, string targ)
-       {
-           cur_targ.Add ("keys", new MBString (key));
-           cur_targ.Add ("vals", targ);
-       }
+       // Dictionaries
 
-       void AddDictionaryResult (string key, Result val)
+       void SetDictionaryRule ()
        {
-           cur_targ.Add ("keys", new MBString (key));
-           cur_targ.Add ("vals", val);
+           cur_constructed.tb.SetRuleType (typeof (MakeDictionaryRule));
        }
 
-       void FinishDictionary (LinkList<TagItem> tags)
+       void AddDictionaryValue (string key, SingleValue val)
        {
-           FinishCurTagged (tags);
+           val.AddAsDictItem (key, cur_constructed.tb);
        }
 
        // Boolean expression helping
 
-       void DefineBoolOpsTarget (string name, BoolOps ops, LinkList<TagItem> 
tags)
+       void SetBoolOpsRule ()
        {
-           if (CheckTargetName (name))
-               return;
+           cur_constructed.tb.RuleName = "Core.BooleanHelper";
+       }
 
-           cur_targ = pb.DefineTarget (name);
-
-           ops.DecodeInto (cur_targ);
-
-           FinishCurTagged (tags);
+       void DecodeBoolOps (BoolOps ops)
+       {
+           ops.DecodeInto (cur_constructed.tb);
        }
 
        enum OpCode {
@@ -674,8 +650,6 @@
                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]);
 
@@ -705,5 +679,32 @@
                tb.Add (new MBString (sb.ToString ()));
            }
        }
+
+       // Formatted string
+
+       void SetupFormat (string format, LinkList<SingleValue> list)
+       {
+           cur_constructed.tb.RuleName = "Core.FormatHelper";
+           cur_constructed.tb.Add ("format", new MBString (format));
+
+           list = Reverse<SingleValue> (list);
+
+           for (; list != null; list = list.prev)
+               list.item.AddAsDefaultOrdered (cur_constructed.tb);
+       }
+
+       // Conditionals
+
+       void SetupConditional (SingleValue cond, SingleValue ifyes, SingleValue 
ifno)
+       {
+           cur_constructed.tb.RuleName = "Core.Switch";
+
+           cond.AddAsDep ("cases", cur_constructed.tb);
+           cur_constructed.tb.Add ("cases", MBBool.True);
+
+           ifyes.AddAsDefaultOrdered (cur_constructed.tb);
+           ifno.AddAsDefaultOrdered (cur_constructed.tb);
+       }
+
     }
 }

Modified: trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser.jay
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser.jay 
2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser.jay 
2006-07-20 03:08:35 UTC (rev 62789)
@@ -48,6 +48,8 @@
 %token NOT           "!"
 %token BOOL_AND      "&&"
 %token BOOL_OR       "||"
+%token PERCENT      "%"
+%token QUESTION             "?"
 
 // the rest
 
@@ -78,16 +80,25 @@
        | inside_statement
        | subdirs_statement
        | load_statement
-       | target_rule_statement
-       | target_only_statement
-       | dictionary_def
-       | boolexpr_def
+       | rule_target_statement
+       | copy_target_statement
        ;
 
+/* Using */
+
 using_statement
-       : USING OPEN_BRACKET identifiers CLOSE_BRACKET
+       : USING OPEN_BRACKET using_items CLOSE_BRACKET
+       ;
+
+using_items
+       : using_item
+       | using_items using_item
+       ;
+
+using_item
+       : IDENTIFIER
        {
-               UseList ((LinkList<string>) $3);
+               UseNamespace ((string) $1);
        }
        ;
 
@@ -112,53 +123,50 @@
                AddProjectProperty ((string) $1, (string) $3);
        }
        | REF OPEN_BRACKET references CLOSE_BRACKET
-       {
-               AddProjectReferences ((LinkList<ANameItem>) $3);
-       }
        ;
 
 references
        : reference
-       {
-               $$ = new LinkList<ANameItem> ((ANameItem) $1);
-       }
        | references reference
-       {
-               $$ = new LinkList<ANameItem> ((ANameItem) $2, 
(LinkList<ANameItem>) $1);
-       }
        ;
 
 reference
        : IDENTIFIER
        {
-               $$ = new ANameItem (BundleManager.MakeName ((string) $1));
+               AddUnversionedReference ((string) $1);
        }
        | IDENTIFIER EQUALS IDENTIFIER
        {
-               $$ = new ANameItem (BundleManager.MakeName ((string) $1, 
(string) $3));
+               AddVersionedReference ((string) $1, (string) $3);
        }
-/* disallow for now -- implementation issues
-       | ATSIGN IDENTIFIER
-       {
-               // Private bundle reference
-               $$ = $2;
-       }
-*/
        ;
 
 /* Inside statements */
 
 inside_statement
-       : INSIDE OPEN_BRACKET identifiers CLOSE_BRACKET OPEN_BRACKET
+       : INSIDE OPEN_BRACKET 
        {
-               StartInsideBases ((LinkList<string>) $3);
+               StartInside ();
        }
-       inside_ok_statements CLOSE_BRACKET
+       inside_items CLOSE_BRACKET 
+       OPEN_BRACKET inside_ok_statements CLOSE_BRACKET
        {
                FinishInside ();
        }
        ;
                
+inside_items
+       : inside_item
+       | inside_items inside_item
+       ;
+
+inside_item
+       : IDENTIFIER
+       {
+               AddInsideBasis ((string) $1);
+       }
+       ;
+
 inside_ok_statements
        : inside_ok_statement
        | inside_ok_statements inside_ok_statement
@@ -171,9 +179,18 @@
 /* Subdirs */
 
 subdirs_statement
-       : SUBDIRS OPEN_BRACKET identifiers CLOSE_BRACKET
+       : SUBDIRS OPEN_BRACKET subdir_items CLOSE_BRACKET
+       ;
+
+subdir_items
+       : subdir_item
+       | subdir_items subdir_item
+       ;
+
+subdir_item
+       : IDENTIFIER
        {
-               DoSubdirList ((LinkList<string>) $3);
+               AddSubdir ((string) $1);
        }
        ;
 
@@ -186,24 +203,28 @@
        }
        ;
 
-/* Target definitions */
+/* Rule target definitions */
 
-target_rule_statement
-       : IDENTIFIER EQUALS IDENTIFIER OPEN_BRACKET opt_dependencies 
CLOSE_BRACKET opt_with
+rule_target_statement
+       : IDENTIFIER EQUALS opt_rulename OPEN_BRACKET 
        {
-               DefineTarget ((string) $1, (string) $3, (LinkList<DepItem>) $5, 
-                                (LinkList<TagItem>) $7);
+               StartTarget ((string) $1);
+
+               if ($3 != null)
+                       SetTargetRuleName ((string) $3);
+
        }
-       ;
-
-target_only_statement
-       : IDENTIFIER EQUALS OPEN_BRACKET opt_dependencies CLOSE_BRACKET opt_with
+       opt_dependencies CLOSE_BRACKET opt_with
        {
-               DefineTarget ((string) $1, null, (LinkList<DepItem>) $4, 
-                                (LinkList<TagItem>) $6);
+               FinishTarget ();
        }
        ;
 
+opt_rulename
+       : /* empty */
+       | IDENTIFIER
+       ;
+
 opt_dependencies
        : /* empty */
        | dependencies
@@ -211,103 +232,145 @@
 
 dependencies
        : dependency
+       | dependencies dependency
+       ;
+
+dependency
+       : dependency_item
+       | IDENTIFIER EQUALS 
        {
-               $$ = new LinkList<DepItem> ((DepItem) $1);
+               cur_arg_name = (string) $1;
        }
-       | dependencies dependency
+       dependency_item
        {
-               $$ = new LinkList<DepItem> ((DepItem) $2, (LinkList<DepItem>) 
$1);
+               cur_arg_name = null;
        }
        ;
 
-dependency
-       : ATSIGN IDENTIFIER
+dependency_item
+       : single_value
        {
-               $$ = new DepItem ((string) $2, true);
+               ((SingleValue) $1).AddAsDep (cur_arg_name, cur_targ);
        }
-       | IDENTIFIER EQUALS ordered_or_simple_dependency
+       | ordered_dependency
        {
-               // arg labelling
-               $$ = new DepItem ((string) $1, $3);
+               ApplyOrderedDeps ((LinkList<SingleValue>) $1);
        }
-       | ordered_or_simple_dependency
+       | ATSIGN IDENTIFIER
        {
-               $$ = new DepItem ($1);
+               AddResponseDependencies ((string) $2);
        }
        ;
 
-simple_dependency
-       : IDENTIFIER
-       | litresult
+ordered_dependency
+       : OPEN_BRACKET ordered_values CLOSE_BRACKET
+       {
+               $$ = $2;
+       }
        ;
 
-simple_dependencies
-       : simple_dependency
+ordered_values
+       : single_value
        {
-               $$ = new LinkList<DepItem> (new DepItem ($1));
+               $$ = new LinkList<SingleValue> ((SingleValue) $1);
        }
-       | simple_dependencies COMMA simple_dependency
+       | ordered_values COMMA single_value
        {
-               $$ = new LinkList<DepItem> (new DepItem ($3), 
(LinkList<DepItem>) $1);
+               $$ = new LinkList<SingleValue> ((SingleValue) $3, 
(LinkList<SingleValue>) $1);
        }
        ;
 
-ordered_dependency
-       : OPEN_BRACE simple_dependencies CLOSE_BRACE
+opt_with
+       : /* empty */
+       | WITH OPEN_BRACKET with_properties CLOSE_BRACKET
+       ;
+
+with_properties
+       : with_property
+       | with_properties with_property
+       ;
+
+with_property
+       : IDENTIFIER EQUALS single_value
        {
-               $$ = $2;
+               AddTargetTag ((string) $1, (SingleValue) $3);
        }
        ;
 
-ordered_or_simple_dependency
-       : ordered_dependency
-       | simple_dependency
-       ;
+/* Straight-copy target */
 
-opt_with
-       : /* empty */
-       | with_statement
+copy_target_statement
+       : IDENTIFIER EQUALS nontarget_value
+       {
+               StartTarget ((string) $1);
+               SetTargetAsValue ((SingleValue) $3);
+       }
+       opt_with
+       {
+               FinishTarget ();
+       }
        ;
 
-with_statement
-       : WITH OPEN_BRACKET with_properties CLOSE_BRACKET
+
+/* low-level */
+
+single_value
+       : nontarget_value
+       | target_name
        {
-               $$ = $3;
+               $$ = new SingleValue ((string) $1);
        }
        ;
 
-with_properties
-       : with_property
+nontarget_value
+       : litresult
        {
-               $$ = new LinkList<TagItem> ((TagItem) $1);
+               $$ = new SingleValue ((Result) $1);
        }
-       | with_properties with_property
+       | constructed_result
        {
-               $$ = new LinkList<TagItem> ((TagItem) $2, (LinkList<TagItem>) 
$1);
+               $$ = new SingleValue ((string) $1);
        }
        ;
 
-with_property
-       : IDENTIFIER EQUALS litresult
+target_name
+       : IDENTIFIER
+       ;
+
+litresult
+       : STRING
        {
-               $$ = new TagItem ((string) $1, $3);
+               $$ = new MBString ((string) $1);
        }
-       | IDENTIFIER EQUALS IDENTIFIER
+       | TRUE
        {
-               $$ = new TagItem ((string) $1, $3);
+               $$ = MBBool.True;
        }
+       | FALSE
+       {
+               $$ = MBBool.False;
+       }
        ;
 
-/* Dictionaries */
+constructed_result
+       : constructed_dictionary
+       | constructed_boolops
+       | constructed_strformat
+       | constructed_conditional
+       ;
 
-dictionary_def
-       : IDENTIFIER EQUALS OPEN_BRACE
+/* Constructed result: Dictionaries */
+
+constructed_dictionary
+       : OPEN_BRACE
        {
-               StartDictionary ((string) $1);
+               StartConstructed ();
+               SetDictionaryRule ();
        }
-       dictitems CLOSE_BRACE opt_with
+       dictitems CLOSE_BRACE
        {
-               FinishDictionary ((LinkList<TagItem>) $7);
+               $$ = cur_constructed.tb.Name;
+               FinishConstructed ();
        }
        ;
 
@@ -317,39 +380,47 @@
        ;
 
 dictitem
-       : IDENTIFIER EQUALS IDENTIFIER
+       : IDENTIFIER EQUALS single_value
        {
-               AddDictionaryTarget ((string) $1, (string) $3);
+               AddDictionaryValue ((string) $1, (SingleValue) $3);
        }
-       | IDENTIFIER EQUALS litresult
-       {
-               AddDictionaryResult ((string) $1, (Result) $3);
-       }
        ;
 
-/* Boolean expressions */
+/* Constructed result: boolean expressions */
 
-boolexpr_def
-       : IDENTIFIER EQUALS boolops opt_with
+constructed_boolops
+       : boolops
        {
-               DefineBoolOpsTarget ((string) $1, (BoolOps) $3, 
(LinkList<TagItem>) $4);
+               StartConstructed ();
+               SetBoolOpsRule ();
+               DecodeBoolOps ((BoolOps) $1);
+               $$ = cur_constructed.tb.Name;
+               FinishConstructed ();
        }
        ;
 
 boolops
-       : OPEN_PARENS boolops CLOSE_PARENS
+       : OPEN_PARENS boolops_or_value CLOSE_PARENS
        {
                $$ = $2;
        }
-       | unary_boolop boolops
+       | unary_boolop boolops_or_value
        {
                $$ = ((BoolOps) $2).CombineUnary ((OpCode) $1);
        }
-       | boolops binary_boolop boolops
+       | boolops_or_value binary_boolop boolops_or_value
        {
                $$ = ((BoolOps) $1).CombineBinary ((OpCode) $2, (BoolOps) $3);
        }
-       | IDENTIFIER
+       ;
+
+boolops_or_value
+       : boolops
+       /* literals and constructeds don't make sense as
+        * inputs to a bool ops, so use target_name, not 
+        * single_value 
+        */
+       | target_name
        {
                $$ = new BoolOps ((string) $1);
        }
@@ -364,34 +435,30 @@
        : NOT { $$ = OpCode.Not; }
        ;
 
-/* low-level */
+/* Constructed result: formatted string */
 
-litresult
-       : STRING
+constructed_strformat
+       : STRING PERCENT ordered_dependency
        {
-               $$ = new MBString ((string) $1);
+               StartConstructed ();
+               SetupFormat ((string) $1, (LinkList<SingleValue>) $3);
+               $$ = cur_constructed.tb.Name;
+               FinishConstructed ();
        }
-       | TRUE
-       {
-               $$ = MBBool.True;
-       }
-       | FALSE
-       {
-               $$ = MBBool.False;
-       }
        ;
+               
+/* Constructed result: conditional */
 
-identifiers
-       : IDENTIFIER
+constructed_conditional
+       : single_value QUESTION single_value COLON single_value
        {
-               $$ = new LinkList<string> ((string) $1);
+               StartConstructed ();
+               SetupConditional ((SingleValue) $1, (SingleValue) $3, 
(SingleValue) $5);
+               $$ = cur_constructed.tb.Name;
+               FinishConstructed ();
        }
-       | identifiers IDENTIFIER
-       {
-               $$ = new LinkList<string> ((string) $2, (LinkList<string>) $1);
-       }
        ;
-
+               
 %%
 
 }

Modified: 
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileProviderLoader.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileProviderLoader.cs  
2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileProviderLoader.cs  
2006-07-20 03:08:35 UTC (rev 62789)
@@ -68,11 +68,9 @@
            foreach (string sub in parser.Subdirs)
                children.Enqueue (new BuildfileProviderLoader (basis + sub, 
ss));
 
-           string[] s = parser.WhereInside;
-
-           if (s != null) {
-               for (int i = 0; i < s.Length; i++)
-                   children.Enqueue (new InsideProviderLoader (basis + s[i], 
parser.InsideNameContext));
+           foreach (BuildfileParser.InsideInfo ii in parser.Insides) {
+               foreach (string s in ii.Bases)
+                   children.Enqueue (new InsideProviderLoader (basis + s, 
ii.Context));
            }
 
            if (parser.ManualLoads != null) {

Modified: trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileTokenizer.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileTokenizer.cs       
2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileTokenizer.cs       
2006-07-20 03:08:35 UTC (rev 62789)
@@ -230,6 +230,10 @@
                                return Token.ATSIGN;
                        if (hint == '!')
                                return Token.NOT;
+                       if (hint == '%')
+                               return Token.PERCENT;
+                       if (hint == '?')
+                               return Token.QUESTION;
                        if (hint == '&') {
                            Read ();
                            if ((char) Peek () != '&')

Modified: trunk/mbuild/Tools.PkgConfig.bundle
===================================================================
--- trunk/mbuild/Tools.PkgConfig.bundle 2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/Tools.PkgConfig.bundle 2006-07-20 03:08:35 UTC (rev 62789)
@@ -208,7 +208,7 @@
                        // Ignore output, just check error condition
                         RunOnce (prog, query, "", out exit_code, out stderr, 
ctxt);
 
-                       res.Value = (exit_code != 0);
+                       res.Value = (exit_code == 0);
  
                         return false;
                @}

Modified: trunk/mbuild/test/ChangeLog
===================================================================
--- trunk/mbuild/test/ChangeLog 2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/test/ChangeLog 2006-07-20 03:08:35 UTC (rev 62789)
@@ -1,3 +1,8 @@
+2006-07-19  Peter Williams  <[EMAIL PROTECTED]>
+
+       * mb-graphstat.cs: Print out the results in the result table, because
+       ... why not?
+
 2006-07-12  Peter Williams  <[EMAIL PROTECTED]>
 
        * mb-graphstat.cs: Little utility that reads a BinarySerializedGraph

Modified: trunk/mbuild/test/mb-graphstat.cs
===================================================================
--- trunk/mbuild/test/mb-graphstat.cs   2006-07-20 02:40:33 UTC (rev 62788)
+++ trunk/mbuild/test/mb-graphstat.cs   2006-07-20 03:08:35 UTC (rev 62789)
@@ -157,6 +157,8 @@
        Console.WriteLine (" * Result table has {0} entries, consumes {1} 
bytes", 
                           rtab.Length, pend - pstart);
 
+       for (int i = 0; i < rtab.Length; i++)
+           Console.WriteLine ("    {0}: {1}", i, rtab[i]);
 
        try {
            br.ReadByte ();

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

Reply via email to