Author: peterw
Date: 2006-07-19 03:12:32 -0400 (Wed, 19 Jul 2006)
New Revision: 62730
Modified:
trunk/mbuild/
trunk/mbuild/Monkeywrench/ChangeLog
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser.jay
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileProviderLoader.cs
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/TargetBuilder.cs
trunk/mbuild/Monkeywrench/Monkeywrench/ProjectManager.cs
Log:
2006-07-19 Peter Williams <[EMAIL PROTECTED]>
* Monkeywrench.Compiler/BuildfileParser.jay: Move as much code as
possible ...
* Monkeywrench.Compiler/BuildfileParserHelper.cs: ... to this file.
Yay partial classes! Clean up the code a bit -- more to come.
* Monkeywrench.Compiler/BuildfileProviderLoader.cs: Track a few
API changes that are side effects of the first cleanups.
* Monkeywrench/ProjectManager.cs (GetGraph): Check if the parsing
failed before serializing the graph.
* Monkeywrench.Compiler/TargetBuilder.cs: Give the full target
name in a few error messages.
Property changes on: trunk/mbuild
___________________________________________________________________
Name: svn:ignore
- *.mdb
*.dll
*.exe
_build
BUILD
make-version.stamp
prefix-config.xml
*.diff
make-prefix.stamp
config.log
config.status
autom4te.cache
configure
Makefile
+ *.mdb
*.dll
*.exe
_build
BUILD
make-version.stamp
prefix-config.xml
*.diff
make-prefix.stamp
config.log
config.status
autom4te.cache
configure
Makefile
CMPBUILD
Modified: trunk/mbuild/Monkeywrench/ChangeLog
===================================================================
--- trunk/mbuild/Monkeywrench/ChangeLog 2006-07-19 05:38:51 UTC (rev 62729)
+++ trunk/mbuild/Monkeywrench/ChangeLog 2006-07-19 07:12:32 UTC (rev 62730)
@@ -1,5 +1,22 @@
2006-07-19 Peter Williams <[EMAIL PROTECTED]>
+ * Monkeywrench.Compiler/BuildfileParser.jay: Move as much code as
+ possible ...
+
+ * Monkeywrench.Compiler/BuildfileParserHelper.cs: ... to this file.
+ Yay partial classes! Clean up the code a bit -- more to come.
+
+ * Monkeywrench.Compiler/BuildfileProviderLoader.cs: Track a few
+ API changes that are side effects of the first cleanups.
+
+ * Monkeywrench/ProjectManager.cs (GetGraph): Check if the parsing
+ failed before serializing the graph.
+
+ * Monkeywrench.Compiler/TargetBuilder.cs: Give the full target
+ name in a few error messages.
+
+2006-07-19 Peter Williams <[EMAIL PROTECTED]>
+
* Monkeywrench.Compiler/GraphBuilder.cs (AddDependentBundles):
Loop through the bundles in the BundleManager and add
DependentItemInfos for them.
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/ProjectManager.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/ProjectManager.cs 2006-07-19
05:38:51 UTC (rev 62729)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/ProjectManager.cs 2006-07-19
07:12:32 UTC (rev 62730)
@@ -93,6 +93,9 @@
Console.WriteLine ("Compiling to {0} ... (FIXME writeline)", gfile);
GraphBuilder gb = GraphCompiler.Compile (ss, log);
+ if (gb == null)
+ return null;
+
BinaryGraphSerializer.Write (gb, gfile);
return LoadSavedGraph (gfile, false);
Modified: trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser.jay
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser.jay
2006-07-19 05:38:51 UTC (rev 62729)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParser.jay
2006-07-19 07:12:32 UTC (rev 62730)
@@ -4,10 +4,6 @@
//
using System;
-using System.Text;
-using System.Collections;
-using System.Reflection;
-using System.IO;
using Mono.Build;
using Mono.Build.RuleLib;
@@ -15,355 +11,8 @@
namespace Monkeywrench.Compiler {
- public class BuildfileParser {
+ public partial class BuildfileParser {
- // Mostly copied from cs-parser.jay
-
- BuildfileTokenizer lexer;
- string location_base;
- string topsrc;
- string resource_subdir;
- ProviderBuilder pb;
- NameLookupContext cur_nlc, inside_nlc;
- ProjectInfo pinfo;
-
- string[] where_inside;
- string[] subdirs;
- Hashtable loads;
-
- int nresource;
- int nerror;
- IWarningLogger log;
-
- static int yacc_verbose_flag = 1;
-
- const string ResourceTarget = ".monkeywrench_resource_";
-
- public static readonly char[] IllegalTargetChars = new char[] {
'+', ':', '/' };
- public static bool DebugParser; // hack hack
-
- TargetBuilder cur_targ = null;
-
- // public
-
- public BuildfileParser (StreamReader reader, string topsrc,
string resource_subdir,
- string location_base, ProviderBuilder pb,
IWarningLogger log)
- {
- lexer = new BuildfileTokenizer (reader);
- this.location_base = location_base;
- this.topsrc = topsrc;
- this.resource_subdir = resource_subdir;
- this.pb = pb;
- this.log = log;
- cur_nlc = pb.NameContext;
-
- nresource = 0;
- nerror = 0;
- }
-
- 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;
- }
-
- public BuildfileTokenizer Lexer {
- get {
- return lexer;
- }
- }
-
- public ProjectInfo PInfo { get { return pinfo; } }
-
- public NameLookupContext InsideNameContext { get { return
inside_nlc; } }
- public string[] WhereInside { get { return where_inside; } }
- public string[] Subdirs { get { return subdirs; } }
- public IDictionary ManualLoads { get { return loads; } }
-
- public string Location {
- get {
-
- return location_base + ':' +
Lexer.LineNum.ToString ();
- }
- }
-
- 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;
- }
-
- // implementation helpers
-
- 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;
- }
- }
-
- class DepList {
- public DepItem item;
- public DepList prev;
-
- public DepList (DepItem item) : this (item, null) {}
-
- public DepList (DepItem item, DepList prev) {
- this.item = item;
- this.prev = prev;
- }
-
- public static DepList Reverse (DepList l) {
- // Algo. copied from g_slist_reverse
-
- DepList prev = null;
-
- while (l != null) {
- DepList next = l.prev;
- l.prev = prev;
-
- prev = l;
- l = next;
- }
-
- return prev;
- }
- }
-
- /* Still waiting for those generics! */
-
- class IdentList {
- public string text;
- public IdentList prev;
-
- public IdentList (string text) : this (text, null) {}
-
- public IdentList (string text, IdentList prev) {
- this.text = text;
- this.prev = prev;
- }
- }
-
- class AssemblyNameList {
- public AssemblyName name;
- public string target;
- public AssemblyNameList prev;
-
- public AssemblyNameList (object o) : this (o, null) {}
-
- public AssemblyNameList (object o, AssemblyNameList
prev) {
- if (o is string)
- this.target = (string) o;
- else
- this.name = (AssemblyName) o;
-
- this.prev = prev;
- }
-
- public AssemblyNameList (AssemblyName name, string
target, AssemblyNameList prev) {
- this.name = name;
- this.target = target;
- this.prev = prev;
- }
- }
-
- class PropList {
- public string name;
- public object val;
- public PropList prev;
-
- public PropList (string name, object val) : this (name,
val, null) {}
-
- public PropList (string name, object val, PropList
prev) {
- this.name = name;
- this.val = val;
- this.prev = prev;
- }
- }
-
- void Warning (int category, string text, string detail) {
- log.PushLocation (Location);
- log.Warning (category, text, detail);
- log.PopLocation ();
- }
-
-#if MAYBE_LATER
- void Warning (int category, string text) {
- Warning (category, text, null);
- }
-#endif
-
- void Error (int category, string text, string detail) {
- log.PushLocation (Location);
- log.Error (category, text, detail);
- log.PopLocation ();
- nerror++;
- }
-
-#if MAYBE_LATER
- void Error (int category, string text) {
- Error (category, text, null);
- }
-#endif
-
- 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;
- }
-
- bool CheckTargetName (string name) {
- if (name[0] == '.') {
- Error (2003, "User-defined target name \'" +
name +
- "\' may not start with \'.\'.", null);
- return false;
- }
-
- int idx = name.IndexOfAny (IllegalTargetChars);
-
- if (idx != -1) {
- Error (2008, "User-defined target name \'" +
name + "\' may not contain \'"
- + name[idx] + "\'.", null);
- return false;
- }
-
- if (!pb.CanDefineTarget (name)) {
- Error (2009, "Target \'" + name + "\' already
defined.", null);
- return false;
- }
-
- return true;
- }
-
- void AddTargetDeps (TargetBuilder tb, DepList deps) {
- for (; deps != null; deps = deps.prev) {
- DepItem dep = deps.item;
-
- //Console.WriteLine ("dep: {0}, {1}, {2}",
dep.arg, dep.name, dep.is_response);
-
- if (dep.is_response) {
- if (!(dep.item is string))
- throw new Exception
(String.Format ("Don't know how to load {0} " +
- "as a response file",
dep.item));
-
- LoadResponseFile (tb, dep.arg, (string)
dep.item);
- continue;
- }
-
- if (dep.item is Result) {
- if (dep.arg != null)
- tb.Add (dep.arg, (Result)
dep.item);
- else
- tb.Add ((Result) dep.item);
- } else if (dep.item is string) {
- if (dep.arg != null)
- tb.Add (dep.arg, (string)
dep.item);
- else
- tb.Add ((string) dep.item);
- } else if (dep.item is DepList) {
- // ordered dependency list
-
- dep.item = DepList.Reverse ((DepList)
dep.item);
-
- for (DepList iter = (DepList) dep.item;
iter != null; iter = iter.prev) {
- DepItem subdep = iter.item;
- object subitem = subdep.item;
-
- if (subitem is Result) {
- if (dep.arg != null)
- tb.Add
(dep.arg, (Result) subitem);
- else
-
tb.AddDefaultOrdered ((Result) subitem);
- } else if (subitem is string) {
- if (dep.arg != null)
- tb.Add
(dep.arg, (string) subitem);
- else
-
tb.AddDefaultOrdered ((string) subitem);
- }
- }
- } else
- throw new Exception ("parse error 52: "
+ dep.item.ToString ());
- }
- }
-
- void AddTargetTags (TargetBuilder tb, PropList props) {
- for (; props != null; props = props.prev) {
- //Console.WriteLine ("tag property: {0} = {1}",
props.name, props.val);
-
- if (props.val is string)
- tb.AddTargetTag (props.name, (string)
props.val);
- else
- tb.AddResultTag (props.name, (Result)
props.val);
- }
- }
-
- 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);
- }
- }
- }
%}
// stuff copied from cs-parser.jay
@@ -416,9 +65,6 @@
buildfile
: statements EOF
- {
- // pb.Done ();
- }
;
statements
@@ -441,61 +87,75 @@
using_statement
: USING OPEN_BRACKET identifiers CLOSE_BRACKET
{
- //Console.WriteLine ("Got using statement.");
- // order of using statements shouldn't matter.
-
- for (IdentList iter = (IdentList) $3; iter != null; iter =
iter.prev) {
- //Console.WriteLine ("Using {0}", iter.text);
-
- if (cur_nlc.UseNamespace (iter.text, 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???");
- }
+ UseList ((LinkList<string>) $3);
}
;
+/* Project statement */
+
project_statement
: PROJECT OPEN_BRACKET
{
- pinfo = new ProjectInfo ();
+ StartProjectInfo ();
}
- properties CLOSE_BRACKET
+ project_properties CLOSE_BRACKET
;
-inside_statement
- : INSIDE OPEN_BRACKET identifiers CLOSE_BRACKET OPEN_BRACKET
+project_properties
+ : project_property
+ | project_properties project_property
+ ;
+
+project_property
+ : IDENTIFIER EQUALS IDENTIFIER
{
- // FIXME: no reason this should be illegal
- if (inside_nlc != null)
- throw new Exception ("Cannot have two inside []
directives in one buildfile");
+ AddProjectProperty ((string) $1, (string) $3);
+ }
+ | REF OPEN_BRACKET references CLOSE_BRACKET
+ {
+ AddProjectReferences ((LinkList<ANameItem>) $3);
+ }
+ ;
- // oh god, the inefficiency
+references
+ : reference
+ {
+ $$ = new LinkList<ANameItem> ((ANameItem) $1);
+ }
+ | references reference
+ {
+ $$ = new LinkList<ANameItem> ((ANameItem) $2,
(LinkList<ANameItem>) $1);
+ }
+ ;
- SortedList sl = new SortedList ();
- for (IdentList iter = (IdentList) $3; iter != null; iter =
iter.prev)
- sl.Add (iter.text, iter.text);
+reference
+ : IDENTIFIER
+ {
+ $$ = new ANameItem (BundleManager.MakeName ((string) $1));
+ }
+ | IDENTIFIER EQUALS IDENTIFIER
+ {
+ $$ = new ANameItem (BundleManager.MakeName ((string) $1,
(string) $3));
+ }
+/* disallow for now -- implementation issues
+ | ATSIGN IDENTIFIER
+ {
+ // Private bundle reference
+ $$ = $2;
+ }
+*/
+ ;
- where_inside = new string[sl.Count];
- // sl.CopyTo crashes (?)
- for (int i = 0; i < sl.Count; i++) {
- string s = (string) sl.GetByIndex (i);
+/* Inside statements */
- // 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;
+inside_statement
+ : INSIDE OPEN_BRACKET identifiers CLOSE_BRACKET OPEN_BRACKET
+ {
+ StartInsideBases ((LinkList<string>) $3);
}
inside_ok_statements CLOSE_BRACKET
{
- cur_nlc = pb.NameContext;
+ FinishInside ();
}
;
@@ -508,86 +168,39 @@
: using_statement
;
+/* Subdirs */
+
subdirs_statement
- : SUBDIRS OPEN_BRACKET identifiers_or_strings CLOSE_BRACKET
+ : SUBDIRS OPEN_BRACKET identifiers CLOSE_BRACKET
{
- int count = 0;
-
- for (IdentList iter = (IdentList) $3; iter != null; iter =
iter.prev)
- count++;
-
- subdirs = new string[count];
- count = 0;
-
- for (IdentList iter = (IdentList) $3; iter != null; iter =
iter.prev) {
- string dir = iter.text;
-
- if (dir.IndexOfAny (Path.GetInvalidPathChars ()) != -1)
{
- Error (2002, "Item \'" + dir + "\'in subdirs
statement contains " +
- "invalid path characters.", null);
- continue;
- }
-
- subdirs[count] = dir + "/";
- count++;
- }
+ DoSubdirList ((LinkList<string>) $3);
}
;
+/* Load statement */
+
load_statement
: LOAD IDENTIFIER INSIDE IDENTIFIER
{
- string file = (string) $2;
- string basis = (string) $4;
-
- if (file.IndexOf (Path.DirectorySeparatorChar) != -1) {
- Error (2010, "Extra build file \'" + file + "\' (loaded
into basis \'" +
- basis + "\') must be in same directory as
declaring build file.", null);
- } else if (basis[0] == '/') {
- Error (2011, "Basis \'" + basis + "\' (declared in file
\'" + file +
- "\') must be relative to declaring basis.",
null);
- } else {
- if (loads == null)
- loads = new Hashtable ();
-
- loads [basis + "/"] = file;
- }
+ DoLoadStatement ((string) $2, (string) $4);
}
;
+/* Target definitions */
+
target_rule_statement
: IDENTIFIER EQUALS IDENTIFIER OPEN_BRACKET opt_dependencies
CLOSE_BRACKET opt_with
{
- string name = (string) $1;
-
- if (CheckTargetName (name)) {
- //Console.WriteLine ("*** Got a target with a rule:
{0}, {1}", $1, $3);
- TargetBuilder tb = pb.DefineTarget (name);
- tb.RuleName = (string) $3;
-
- if ($5 != null)
- AddTargetDeps (tb, (DepList) $5);
- if ($7 != null)
- AddTargetTags (tb, (PropList) $7);
- }
+ DefineTarget ((string) $1, (string) $3, (LinkList<DepItem>) $5,
+ (LinkList<TagItem>) $7);
}
;
target_only_statement
: IDENTIFIER EQUALS OPEN_BRACKET opt_dependencies CLOSE_BRACKET opt_with
{
- string name = (string) $1;
-
- if (CheckTargetName (name)) {
- //Console.WriteLine ("*** Got a target without a
rule.");
- TargetBuilder tb = pb.DefineTarget ((string) $1);
- tb.RuleName = null;
-
- if ($4 != null)
- AddTargetDeps (tb, (DepList) $4);
- if ($6 != null)
- AddTargetTags (tb, (PropList) $6);
- }
+ DefineTarget ((string) $1, null, (LinkList<DepItem>) $4,
+ (LinkList<TagItem>) $6);
}
;
@@ -599,11 +212,11 @@
dependencies
: dependency
{
- $$ = new DepList ((DepItem) $1);
+ $$ = new LinkList<DepItem> ((DepItem) $1);
}
| dependencies dependency
{
- $$ = new DepList ((DepItem) $2, (DepList) $1);
+ $$ = new LinkList<DepItem> ((DepItem) $2, (LinkList<DepItem>)
$1);
}
;
@@ -631,11 +244,11 @@
simple_dependencies
: simple_dependency
{
- $$ = new DepList (new DepItem ($1));
+ $$ = new LinkList<DepItem> (new DepItem ($1));
}
| simple_dependencies COMMA simple_dependency
{
- $$ = new DepList (new DepItem ($3), (DepList) $1);
+ $$ = new LinkList<DepItem> (new DepItem ($3),
(LinkList<DepItem>) $1);
}
;
@@ -665,60 +278,36 @@
with_properties
: with_property
+ {
+ $$ = new LinkList<TagItem> ((TagItem) $1);
+ }
| with_properties with_property
{
- ((PropList) $2).prev = (PropList) $1;
- $$ = $2;
+ $$ = new LinkList<TagItem> ((TagItem) $2, (LinkList<TagItem>)
$1);
}
;
with_property
: IDENTIFIER EQUALS litresult
{
- $$ = new PropList ((string) $1, $3);
+ $$ = new TagItem ((string) $1, $3);
}
| IDENTIFIER EQUALS IDENTIFIER
{
- $$ = new PropList ((string) $1, $3);
+ $$ = new TagItem ((string) $1, $3);
}
;
-litresult
- : STRING
- {
- $$ = new MBString ((string) $1);
- }
- | TRUE
- {
- $$ = MBBool.True;
- }
- | FALSE
- {
- $$ = MBBool.False;
- }
- ;
-
/* Dictionaries */
dictionary_def
: IDENTIFIER EQUALS OPEN_BRACE
{
- // we'll exit right after parse, doesn't matter
- // if the target is still defined.
-
- CheckTargetName ((string) $1);
-
- cur_targ = pb.DefineTarget ((string) $1);
- cur_targ.SetRuleType (typeof (MakeDictionaryRule));
+ StartDictionary ((string) $1);
}
dictitems CLOSE_BRACE opt_with
{
- //Console.WriteLine ("want proplist: {0} {1} {2} {3}", $4, $5,
$6, $7);
-
- if ($7 != null)
- AddTargetTags (cur_targ, (PropList) $7);
-
- cur_targ = null;
+ FinishDictionary ((LinkList<TagItem>) $7);
}
;
@@ -730,42 +319,20 @@
dictitem
: IDENTIFIER EQUALS IDENTIFIER
{
- cur_targ.Add ("keys", new MBString ((string) $1));
- cur_targ.Add ("vals", (string) $3);
+ AddDictionaryTarget ((string) $1, (string) $3);
}
| IDENTIFIER EQUALS litresult
{
- cur_targ.Add ("keys", new MBString ((string) $1));
- cur_targ.Add ("vals", (Result) $3);
+ AddDictionaryResult ((string) $1, (Result) $3);
}
;
-identifiers
- : IDENTIFIER
- {
- $$ = new IdentList ((string) $1);
- }
- | identifiers IDENTIFIER
- {
- $$ = new IdentList ((string) $2, (IdentList) $1);
- }
- ;
-
/* Boolean expressions */
boolexpr_def
: IDENTIFIER EQUALS boolops opt_with
{
- CheckTargetName ((string) $1);
-
- cur_targ = pb.DefineTarget ((string) $1);
-
- BuildfileParserHelper.DecodeBoolOps
((BuildfileParserHelper.BoolOps) $3, cur_targ);
-
- if ($4 != null)
- AddTargetTags (cur_targ, (PropList) $4);
-
- cur_targ = null;
+ DefineBoolOpsTarget ((string) $1, (BoolOps) $3,
(LinkList<TagItem>) $4);
}
;
@@ -776,120 +343,55 @@
}
| unary_boolop boolops
{
- $$ = BuildfileParserHelper.CombineUnary
((BuildfileParserHelper.OpCode) $1,
-
(BuildfileParserHelper.BoolOps) $2);
+ $$ = ((BoolOps) $2).CombineUnary ((OpCode) $1);
}
| boolops binary_boolop boolops
{
- $$ = BuildfileParserHelper.CombineBinary
((BuildfileParserHelper.BoolOps) $1,
-
(BuildfileParserHelper.OpCode) $2,
-
(BuildfileParserHelper.BoolOps) $3);
+ $$ = ((BoolOps) $1).CombineBinary ((OpCode) $2, (BoolOps) $3);
}
| IDENTIFIER
{
- $$ = new BuildfileParserHelper.BoolOps ((string) $1);
+ $$ = new BoolOps ((string) $1);
}
;
binary_boolop
- : BOOL_AND { $$ = BuildfileParserHelper.OpCode.And; }
- | BOOL_OR { $$ = BuildfileParserHelper.OpCode.Or; }
+ : BOOL_AND { $$ = OpCode.And; }
+ | BOOL_OR { $$ = OpCode.Or; }
;
unary_boolop
- : NOT { $$ = BuildfileParserHelper.OpCode.Not; }
+ : NOT { $$ = OpCode.Not; }
;
-/* Identifiers or literal strings - where spaces in names are desired */
+/* low-level */
-identifiers_or_strings
- : IDENTIFIER
+litresult
+ : STRING
{
- $$ = new IdentList ((string) $1);
+ $$ = new MBString ((string) $1);
}
- | STRING
+ | TRUE
{
- $$ = new IdentList ((string) $1);
+ $$ = MBBool.True;
}
- | identifiers IDENTIFIER
+ | FALSE
{
- $$ = new IdentList ((string) $2, (IdentList) $1);
+ $$ = MBBool.False;
}
- | identifiers STRING
- {
- $$ = new IdentList ((string) $2, (IdentList) $1);
- }
;
-/* This hack makes it so commas don't screw us up */
-
-references
- : reference
- {
- $$ = new AssemblyNameList ($1);
- }
- | references reference
- {
- $$ = new AssemblyNameList ($2, (AssemblyNameList) $1);
- }
- ;
-
-reference
+identifiers
: IDENTIFIER
{
- $$ = BundleManager.MakeName ((string) $1);
+ $$ = new LinkList<string> ((string) $1);
}
- | IDENTIFIER EQUALS IDENTIFIER
+ | identifiers IDENTIFIER
{
- $$ = BundleManager.MakeName ((string) $1, (string) $3);
+ $$ = new LinkList<string> ((string) $2, (LinkList<string>) $1);
}
-/* disallow for now -- implementation issues
- | ATSIGN IDENTIFIER
- {
- // Private bundle reference
- $$ = $2;
- }
-*/
;
-properties
- : property
- | properties property
- ;
-
-property
- : IDENTIFIER EQUALS IDENTIFIER
- {
- string name = (string) $1;
- string val = (string) $3;
-
- switch (name) {
- case "name":
- pinfo.Name = val;
- break;
- case "version":
- pinfo.Version = val;
- break;
- case "compat-code":
- pinfo.CompatCode = val;
- break;
- default:
- Warning (2004, "Unknown project property \'" + name +
- "\' (value: \'" + val + "\').", null);
- break;
- }
- }
- | REF OPEN_BRACKET references CLOSE_BRACKET
- {
- for (AssemblyNameList iter = (AssemblyNameList) $3; iter !=
null; iter = iter.prev) {
- if (iter.name != null)
- pinfo.AddRef (iter.name);
- else
- pinfo.AddPrivateRef (iter.target);
- }
- }
- ;
-
%%
}
Modified:
trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs
2006-07-19 05:38:51 UTC (rev 62729)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileParserHelper.cs
2006-07-19 07:12:32 UTC (rev 62730)
@@ -1,5 +1,8 @@
using System;
using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
using System.Text;
using Mono.Build;
@@ -8,147 +11,699 @@
namespace Monkeywrench.Compiler {
- public class BuildfileParserHelper {
+ public partial class BuildfileParser {
- // Should eventually move as much C# code as possible into this
- // file from BuildfileParser.jay. Syntax highlighting is pretty
- // useful.
+ BuildfileTokenizer lexer;
- public BuildfileParserHelper () {}
+ string location_base;
+ string topsrc;
+ string resource_subdir;
+ ProviderBuilder pb;
+ IWarningLogger log;
- // Boolean expression helping
+ NameLookupContext cur_nlc;
- public enum OpCode {
- Not = -1,
- And = -2,
- Or = -3
+ 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 struct BoolOps {
- public int[] commands;
- public string[] targets;
+ public static BuildfileParser CreateForFile (string topsrc, string
srcrel,
+ ProviderBuilder pb,
IWarningLogger log)
+ {
+ string file = Path.Combine (topsrc, srcrel);
- public BoolOps (string targ) {
- commands = new int[1] { 0 };
- targets = new string[1] { targ };
+ 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;
+ }
- public BoolOps (OpCode unary_op, string targ) {
- if (unary_op != OpCode.Not)
- throw new InvalidOperationException ();
+ // Misc
- commands = new int[2] { 0, (int) unary_op };
- targets = new string[1] { targ };
+ 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;
+ }
}
- static public BoolOps CombineUnary (OpCode unary_op, BoolOps operand) {
- if (unary_op != OpCode.Not)
- throw new InvalidOperationException ();
+ // Weird errors occur when this is made a static
+ // member of LinkList. But no biggie.
- BoolOps res = new BoolOps ();
- res.targets = operand.targets;
+ 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;
+ }
- res.commands = new int[operand.commands.Length + 1];
- operand.commands.CopyTo (res.commands, 0);
- res.commands[operand.commands.Length] = (int) unary_op;
+ // Logging with location
- return res;
+ string Location
+ {
+ get {
+ return location_base + ':' + lexer.LineNum.ToString ();
+ }
}
- static public BoolOps CombineBinary (BoolOps left, OpCode op, BoolOps
right)
+ void Warning (int category, string text, string detail)
{
- if (op == OpCode.Not)
- throw new InvalidOperationException ();
+ log.PushLocation (Location);
+ log.Warning (category, text, detail);
+ log.PopLocation ();
+ }
- Hashtable targmap = new Hashtable ();
- ArrayList targlist = new ArrayList ();
- int targindex = 0;
- int lclen = left.commands.Length, rclen = right.commands.Length;
- BoolOps res = new BoolOps ();
+ void WarningV (int category, string fmt, params object[] items)
+ {
+ Warning (category, String.Format (fmt, items), null);
+ }
- int idx = 0;
- res.commands = new int[lclen + rclen + 1];
+ int nerror = 0;
- for (int i = 0; i < lclen; i++) {
- if (left.commands[i] < 0) {
- res.commands[idx++] = left.commands[i];
- continue;
- }
+ void Error (int category, string text, string detail)
+ {
+ log.PushLocation (Location);
+ log.Error (category, text, detail);
+ log.PopLocation ();
+ nerror++;
+ }
- string targ = left.targets[left.commands[i]];
+ void ErrorV (int category, string fmt, params object[] items)
+ {
+ Error (category, String.Format (fmt, items), null);
+ }
- if (targmap.Contains (targ))
- res.commands[idx++] = (int) targmap[targ];
- else {
- targmap[targ] = targindex;
- targlist.Add (targ);
- res.commands[idx++] = targindex++;
+ // 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);
}
}
+ }
- for (int i = 0; i < rclen; i++) {
- if (right.commands[i] < 0) {
- res.commands[idx++] = right.commands[i];
+ // 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;
}
- string targ = right.targets[right.commands[i]];
+ subdirs.Add (dir + "/");
+ }
+ }
- if (targmap.Contains (targ))
- res.commands[idx++] = (int) targmap[targ];
- else {
- targmap[targ] = targindex;
- targlist.Add (targ);
- res.commands[idx++] = targindex++;
+ // 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;
- res.commands[idx] = (int) op;
+ public TagItem (string name, object val)
+ {
+ this.name = name;
+ this.val = val;
+ }
- res.targets = new string[targlist.Count];
- targlist.CopyTo (res.targets);
+ public void AddTo (TargetBuilder tb)
+ {
+ if (val is string)
+ tb.AddTargetTag (name, (string) val);
+ else
+ tb.AddResultTag (name, (Result) val);
+ }
+ }
- return res;
+ // Dictionaries
+
+ TargetBuilder cur_targ = null;
+
+ void FinishCurTagged (LinkList<TagItem> tags)
+ {
+ for (; tags != null; tags = tags.prev)
+ tags.item.AddTo (cur_targ);
+
+ cur_targ = null;
}
- static public void DecodeBoolOps (BoolOps ops, TargetBuilder tb)
+ void StartDictionary (string name)
{
- // This limitation is only because I am lazy and want one character
- // per BooleanHelper command.
+ // we'll exit right after parse, doesn't matter
+ // if the target is still defined.
- if (ops.targets.Length > 10)
- throw new InvalidOperationException ("Limited to 10 or fewer
boolean operands");
+ if (CheckTargetName (name))
+ return;
- tb.RuleName = "Core.BooleanHelper";
+ cur_targ = pb.DefineTarget (name);
+ cur_targ.SetRuleType (typeof (MakeDictionaryRule));
+ }
- for (int i = 0; i < ops.targets.Length; i++)
- tb.AddDefaultOrdered (ops.targets[i]);
+ void AddDictionaryTarget (string key, string targ)
+ {
+ cur_targ.Add ("keys", new MBString (key));
+ cur_targ.Add ("vals", targ);
+ }
- StringBuilder sb = new StringBuilder ();
+ void AddDictionaryResult (string key, Result val)
+ {
+ cur_targ.Add ("keys", new MBString (key));
+ cur_targ.Add ("vals", val);
+ }
- for (int i = 0; i < ops.commands.Length; i++) {
- switch (ops.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 " +
- ops.commands[i].ToString ());
+ 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;
}
- tb.Add (new MBString (sb.ToString ()));
+ 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/Monkeywrench.Compiler/BuildfileProviderLoader.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileProviderLoader.cs
2006-07-19 05:38:51 UTC (rev 62729)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/BuildfileProviderLoader.cs
2006-07-19 07:12:32 UTC (rev 62730)
@@ -65,15 +65,11 @@
new ProjectProvider
(parser.PInfo)));
}
- string[] s = parser.Subdirs;
+ foreach (string sub in parser.Subdirs)
+ children.Enqueue (new BuildfileProviderLoader (basis + sub,
ss));
- if (s != null) {
- for (int i = 0; i < s.Length; i++)
- children.Enqueue (new BuildfileProviderLoader (basis +
s[i], ss));
- }
+ string[] s = parser.WhereInside;
- s = parser.WhereInside;
-
if (s != null) {
for (int i = 0; i < s.Length; i++)
children.Enqueue (new InsideProviderLoader (basis + s[i],
parser.InsideNameContext));
Modified: trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/TargetBuilder.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/TargetBuilder.cs
2006-07-19 05:38:51 UTC (rev 62729)
+++ trunk/mbuild/Monkeywrench/Monkeywrench.Compiler/TargetBuilder.cs
2006-07-19 07:12:32 UTC (rev 62730)
@@ -336,7 +336,7 @@
ruletype = nlc.TryTargetRuleMatch (name, logger);
if (ruletype == null) {
- logger.Error (2028, "Cannot guess the rule for this
target", name);
+ logger.Error (2028, "Cannot guess the rule for this
target", basis + name);
return true;
}
}
@@ -344,7 +344,7 @@
if (!ruletype.IsSubclassOf (typeof (Rule))) {
string s = String.Format ("Invalid rule `{0}\' for target {1}:
not a subclass of Rule",
- ruletype, name);
+ ruletype, basis + name);
logger.Error (2029, s, ruletype.GetType ().FullName);
return true;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches