public BitPatternInvokeArgumentEntry(BitPattern parent, Token[] toks, ref int curIdx)
			{
				Token tok;
				tok = toks[curIdx];
				if (tok.Type != TokenType.Identifier)
					throw new Exception("Expected an identifier for the name of the argument to map to!");
				Name = tok.Value;
				curIdx++;

				tok = toks[curIdx];
				if (tok.Type != TokenType.Equal)
					throw new Exception("Expected an equals sign before the value to pass for the argument!");
				curIdx++;

				ArgValue = new BitPatternPieceOperation(parent, toks, ref curIdx);
			}
		public static void RegisterAlias(string aliasName, BitPattern pat)
		{
			if (Patterns.ContainsKey(aliasName))
				throw new Exception("The BitPattern '" + aliasName + "' was already defined!");
			Patterns[aliasName] = pat;
		}
		public BitPatternPiece(BitPattern parent, Token[] toks, ref int curIdx)
		{
			Token tok;
			tok = toks[curIdx];
			while (tok.Type != TokenType.RParen)
			{
				var bpp = new BitPatternPieceOperation(parent, toks, ref curIdx);
				TotalLength += bpp.Length;
				Operations.Add(bpp);
				tok = toks[curIdx];
			}
			curIdx++;
		}
		public static void RegisterBitPattern(BitPattern pat)
		{
			if (Patterns.ContainsKey(pat.Name))
				throw new Exception("The BitPattern '" + pat.Name + "' was already defined!");
			Patterns[pat.Name] = pat;
		}
		public BitPatternPieceOperation(BitPattern parent, Token[] toks, ref int curIdx)
		{
			Parent = parent;
			Token tok;
			tok = toks[curIdx];
			if (tok.Type == TokenType.Identifier)
			{
				OpType = OperationType.Arg;
				if (!int.TryParse(tok.Value.Substring(1), out ArgIdx))
					throw new Exception("Unknown argument '" + tok.Value + "'!");
				curIdx++;
				tok = toks[curIdx];
				if (tok.Type != TokenType.LSqBracket)
					throw new Exception("Expected the opening square bracket for the bit pattern operation selector!");
				curIdx++;
				Range = new BitRange(toks, ref curIdx);
				parent.RequestArg(ArgIdx, Range.EndIdx);
			}
			else if (tok.Type == TokenType.Number)
			{
				OpType = OperationType.Literal;
				Literal = tok.NumberValue.Value;
				Number n = tok.NumberValue;
				curIdx++;

				tok = toks[curIdx];
				if (n.Format == NumberFormat.Binary)
				{
					if (tok.Type != TokenType.LSqBracket)
					{
						Range = new BitRange(0, n.LiteralLength - 1);
					}
					else
					{
						curIdx++;
						Range = new BitRange(toks, ref curIdx);
					}
				}
				else if (tok.Type != TokenType.LSqBracket)
				{
					Range = new BitRange(0, Utils.GetHighestBitIndexSet(Literal));
				}
				else
				{
					curIdx++;
					Range = new BitRange(toks, ref curIdx);
				}
			}
			else if (tok.Type == TokenType.LParen)
			{
				curIdx++;
				OpType = OperationType.BinaryOp;

				tok = toks[curIdx];
				switch(tok.Type)
				{
					case TokenType.Star:
						BinaryOp = CodeBinaryOperatorType.Multiply;
						break;
					case TokenType.Plus:
						BinaryOp = CodeBinaryOperatorType.Add;
						break;
					default:
						throw new Exception("Unknown math operation to perform!");
				}
				curIdx++;

				LHand = new BitPatternPieceOperation(parent, toks, ref curIdx);
				RHand = new BitPatternPieceOperation(parent, toks, ref curIdx);

				tok = toks[curIdx];
				if (tok.Type != TokenType.RParen)
					throw new Exception("Expected a closing parenthesis!");
				curIdx++;

				tok = toks[curIdx];
				if (tok.Type != TokenType.LSqBracket)
				{
					Range = new BitRange(0, 32);
				}
				else
				{
					curIdx++;
					Range = new BitRange(toks, ref curIdx);
				}
			}
			else if (tok.Type == TokenType.Cash)
			{
				InvokedPatternArgMapping = new List<BitPatternInvokeArgumentEntry>();
				OpType = OperationType.PatternInvoke;
				curIdx++;

				tok = toks[curIdx];
				if (tok.Type != TokenType.Identifier)
					throw new Exception("Expected an identifier for the bit pattern to invoke!");
				InvokedPattern = BitPatternRegistry.GetPattern(tok.Value);
				curIdx++;

				tok = toks[curIdx];
				if (tok.Type != TokenType.LSqBracket)
					throw new Exception("Expected a left square bracket for the arguments to the bit operation!");
				curIdx++;

				tok = toks[curIdx];
				bool expectsArg = true;
				bool first = true;
				while(tok.Type != TokenType.RSqBracket)
				{
					if (!expectsArg)
						throw new Exception("Expected a closing square bracket for the arguments to the bit operation!");
					InvokedPatternArgMapping.Add(new BitPatternInvokeArgumentEntry(parent, toks, ref curIdx));

					tok = toks[curIdx];
					if (tok.Type == TokenType.Comma)
					{
						curIdx++;
						tok = toks[curIdx];
					}
					else
					{
						expectsArg = false;
					}
					first = false;
				}
				if (expectsArg && !first)
					throw new Exception("Expected another argument!");
				curIdx++;
			}
			else
			{
				throw new Exception("Unsupported bit pattern operation!");
			}
		}