Beispiel #1
0
 protected OptionalParser(OptionalParser other, ParserCloneArgs chain)
     : base(other, chain)
 {
 }
Beispiel #2
0
		Parser Factor(Match match, bool isTerminal)
		{
			var primary = Primary(match["primary"], isTerminal);
			var cardinality = match["cardinality"];
			if (cardinality)
			{
				switch (cardinality.Text)
				{
					case "?":
						primary = new OptionalParser(primary);
						break;
					case "*":
						primary = new RepeatParser(primary, 0);
						break;
					case "+":
						primary = new RepeatParser(primary, 1);
						break;
					default:
						throw new FormatException(string.Format("Cardinality '{0}' is unknown", cardinality.Text));
						break;
				}
			}
			var integer = match["integer"];
			if (integer)
				return new RepeatParser(primary, Int32.Parse(integer.Text));
			else
				return primary;
		}
		protected OptionalParser(OptionalParser other, ParserCloneArgs chain)
			: base(other, chain)
		{
		}