public void CharacterInSet(string ch, bool inSet, string unicodeName) { Codepoint parsedChar; if (ch.StartsWith("\\")) { Assert.True(((RangeSetHandle.Static)RegexMatchSet.ParseEscape(ch)).TryGetSingle(out parsedChar)); } else { parsedChar = ch.Single(); } Assert.Equal(inSet, UnicodeRanges.FromUnicodeName(unicodeName).Contains(parsedChar)); }
private void ProcessTerminal(SymbolId symbol, Capture <char> capture) { switch ((int)symbol) { case RegexLexer.SymWhitespace: if (!this.IgnorePatternWhitespace) { foreach (var ch in capture) { this.currentGroup.AppendExpression(RegexMatchSet.FromChars(ch)); } } break; case RegexLexer.SymSlash: if (this.BreakOnSlash) { goto case int.MinValue; // EOF } this.currentGroup.AppendExpression(RegexMatchSet.FromCodepoints('/')); break; case RegexLexer.SymCharset: this.currentGroup.AppendExpression(RegexMatchSet.FromNamedCharset(capture.AsString())); break; case RegexLexer.SymRegexLetter: this.currentGroup.AppendExpression(RegexMatchGrapheme.Create(capture.AsString())); break; case RegexLexer.SymRegexEscape: this.currentGroup.AppendExpression(RegexMatchSet.FromEscape(capture.AsString())); break; case RegexLexer.SymRegexCharset: this.currentGroup.AppendExpression(RegexMatchSet.FromSet(capture.AsString())); break; case RegexLexer.SymRegexDot: this.currentGroup.AppendExpression(RegexMatchSet.Dot()); break; case RegexLexer.SymQuantifyKleene: this.currentGroup.Quantify(RegexQuantifier.Kleene()); break; case RegexLexer.SymQuantifyAny: this.currentGroup.Quantify(RegexQuantifier.Any()); break; case RegexLexer.SymQuantifyOptional: this.currentGroup.Quantify(RegexQuantifier.Optional()); break; case RegexLexer.SymQuantifyRepeat: this.currentGroup.Quantify(RegexQuantifier.Repeat(capture.AsString())); break; case RegexLexer.SymAlternate: this.currentGroup.Alternate(); break; case RegexLexer.SymBeginGroup: this.currentGroup = this.currentGroup.BeginGroup(null); break; case RegexLexer.SymSensitiveGroup: this.currentGroup = this.currentGroup.BeginGroup(true); break; case RegexLexer.SymInsensitiveGroup: this.currentGroup = this.currentGroup.BeginGroup(false); break; case RegexLexer.SymEndGroup: this.currentGroup = this.currentGroup.EndGroup(); break; case int.MinValue: // EOF if (!this.currentGroup.IsRoot) { throw new InvalidOperationException("Regex has open groups"); } this.parseCallback?.Invoke(this.Flush()); break; default: throw new NotSupportedException("Unexpected symbol at index " + capture.Index); } }
public RegexExpression MatchSet(RegexMatchSet node, KeyValuePair <SymbolId, int?> context) { return(RegexAccept.Create(node, context.Key, context.Value)); }
public RxNode <TLetter> MatchSet(RegexMatchSet node, Context context) { return(context.Mapper.MapCodepoints(node.Handle.Negate, node.Handle.GetCharSet(context.CharSetProvider), context.CaseSensitive)); }