}
}
- public IDictionary GetMapping () {
+ public IDictionary GetMapping ()
+ {
Hashtable mapping = new Hashtable ();
- Hashtable numbers = new Hashtable ();
int end = caps.Count;
mapping.Add ("0", 0);
for (int i = 0; i < end; i++) {
CapturingGroup group = (CapturingGroup) caps [i];
- if (group.Name != null && !mapping.Contains (group.Name)) {
+ if (group.Name != null) {
+ if (mapping.Contains (group.Name)) {
+ if ((int) mapping [group.Name] != group.Number)
+ throw new SystemException ("invalid state");
+ continue;
+ }
mapping.Add (group.Name, group.Number);
- numbers.Add (group.Number, group.Number);
+ } else {
+ mapping.Add (group.Number.ToString (), group.Number);
}
}
- for (int i = 1; i < end; i++) {
- if (numbers [i] == null)
- mapping.Add (i.ToString (), i);
- }
-
return mapping;
}
}
else { // capture test
++ ptr;
- asn = new CaptureAssertion ();
+ asn = new CaptureAssertion (new Literal (name, IsIgnoreCase (options)));
refs.Add (asn, name);
}
/* check bounds and ordering */
- if (n >= 0xffff || m >= 0xffff)
- throw NewParseException ("Illegal {x, y} - maximum of 65535.");
+ if (n > 0x7fffffff || m > 0x7fffffff)
+ throw NewParseException ("Illegal {x, y} - maximum of 2147483647.");
if (m >= 0 && m < n)
throw NewParseException ("Illegal {x, y} with x > y.");
if (m > 0)
max = m;
else
- max = 0xffff;
+ max = 0x7fffffff;
return true;
}
foreach (Expression expr in refs.Keys) {
string name = (string)refs[expr];
if (!dict.Contains (name)) {
+ if (expr is CaptureAssertion && !Char.IsDigit (name [0]))
+ continue;
throw NewParseException ("Reference to undefined group " +
(Char.IsDigit (name[0]) ? "number " : "name ") +
name);