public void Initialize() { var cr = Grammar.Rule("CR"); var lf = Grammar.Rule("LF"); InnerLexer = Concatenation.Create(cr, lf); }
public void Initialize() { var wsp = Grammar.Rule("WSP"); var crlf = Grammar.Rule("CRLF"); InnerLexer = Repetition.Create(Alternation.Create(wsp, Concatenation.Create(crlf, wsp)), 0, int.MaxValue); }
public override void Process(TransformContext context) { var concat1 = (Concatenation)context.MatchedLayers[0]; var concat2 = (Concatenation)context.MatchedLayers[1]; var output = concat2.Output; var inputs = new List <OutputConnector>(); foreach (var item in concat2.Inputs.Select(x => x.Connection.From)) { if (item == concat1.Output) { inputs.AddRange(concat1.Inputs.Select(x => x.Connection.From)); } else { inputs.Add(item); } } var newConcat = new Concatenation(inputs.Select(x => new ReadOnlyMemory <int>(x.Dimensions.ToArray()))); for (int i = 0; i < inputs.Count; i++) { newConcat.Inputs[i].SetConnection(inputs[i]); } var oldOuts = output.Connections.Select(o => o.To).ToList(); foreach (var oldOut in oldOuts) { oldOut.SetConnection(newConcat.Output); } }
public override ILexer <IPvFuture> Create() { // "v" var v = Terminal.Create(@"v", StringComparer.OrdinalIgnoreCase); // "." var dot = Terminal.Create(@".", StringComparer.Ordinal); // ":" var colon = Terminal.Create(@":", StringComparer.Ordinal); // 1*HEXDIG var hexadecimalDigitLexer = HexadecimalDigitLexerFactory.Create(); var r = Repetition.Create(hexadecimalDigitLexer, 1, int.MaxValue); // unreserved / sub-delims / ":" var unreservedLexer = UnreservedLexerFactory.Create(); var subcomponentsDelimiterLexer = SubcomponentsDelimiterLexerFactory.Create(); var a = Alternation.Create(unreservedLexer, subcomponentsDelimiterLexer, colon); // 1*( unreserved / sub-delims / ":" ) var s = Repetition.Create(a, 1, int.MaxValue); // "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) var innerLexer = Concatenation.Create(v, r, dot, s); // IPvFuture return(new IPvFutureLexer(innerLexer)); }
/// <summary> /// Recursive function for finding sequence of Terminals and NonTerminals by rule. Result is IEBNFItem which containst sequence /// </summary> private IEBNFItem GetEBNFItem(string rule, List <NonTerminal> listOfExistedTerminals, string endNotation = null) { IEBNFItem result = null; var left = GetStartEBNFItem(rule, listOfExistedTerminals); var lengthOfLeftRule = left.Rebuild().Length; var restOfRule = rule.Substring(lengthOfLeftRule, rule.Length - lengthOfLeftRule); if (string.IsNullOrEmpty(restOfRule)) { throw new GrammarParseException("Can't find IEBNFItem, rest of rule is null or empty. Check termination charatcter."); } var firstChar = restOfRule[0].ToString(); if (!string.IsNullOrEmpty(endNotation) && firstChar.Equals(endNotation)) { result = left; } else if (IsTermination(firstChar)) { result = left; } else { var newRule = restOfRule.Substring(1, restOfRule.Length - 1); var right = GetEBNFItem(newRule, listOfExistedTerminals, endNotation); switch (firstChar) { case Alternation.notation: result = new Alternation(left, right); break; case Concatenation.notation: result = new Concatenation(left, right, this._cacheLength); break; } } return(result); }
public ConcatenationLayerArgument Convert(Concatenation layer, ConvertContext context) { return(new ConcatenationLayerArgument { InputCount = (uint)layer.Inputs.Count }); }
public override ILexer <IPLiteral> Create() { var a = Terminal.Create(@"[", StringComparer.Ordinal); var b = Terminal.Create(@"]", StringComparer.Ordinal); var alt = Alternation.Create(IPv6AddressLexerFactory.Create(), IPvFutureLexerFactory.Create()); var innerLexer = Concatenation.Create(a, alt, b); return(new IPLiteralLexer(innerLexer)); }
public override ILexer <TransferCodingCollection> Create() { var innerLexer = Alternation.Create( Terminal.Create(@"trailers", StringComparer.OrdinalIgnoreCase), Concatenation.Create( TransferCodingLexerFactory.Create(), Option.Create(TransferCodingRankLexerFactory.Create()))); return(new TransferCodingCollectionLexer(innerLexer)); }
public override ILexer <PercentEncoding> Create() { var hexDigitLexer = HexadecimalDigitLexerFactory.Create(); var percentEncodingAlternationLexer = Concatenation.Create( Terminal.Create(@"%", StringComparer.Ordinal), hexDigitLexer, hexDigitLexer); return(new PercentEncodingLexer(percentEncodingAlternationLexer)); }
public override ILexer <TrailerPart> Create() { var innerLexer = Repetition.Create( Concatenation.Create(HeaderFieldLexerFactory.Create(), NewLineLexerFactory.Create()), 0, int.MaxValue); return(new TrailerPartLexer(innerLexer)); }
public override ILexer <ChunkedBody> Create() { var innerLexer = Concatenation.Create( Repetition.Create(ChunkLexerFactory.Create(), 0, int.MaxValue), LastChunkLexerFactory.Create(), TrailerPartLexerFactory.Create(), NewLineLexerFactory.Create()); return(new ChunkedBodyLexer(innerLexer)); }
public override ILexer <OriginForm> Create() { var innerLexer = Concatenation.Create( AbsolutePathLexerFactory.Create(), Option.Create( Concatenation.Create( Terminal.Create(@"?", StringComparer.Ordinal), QueryLexerFactory.Create()))); return(new OriginFormLexer(innerLexer)); }
private byte[] GetBytes9(Concatenation concatenation) { var ctx = new BytesFactoryContext(); var opt1 = (Repetition)concatenation[0]; if (opt1.Count != 0) { GetBytesh16Alt7((Alternation)opt1[0], ctx); } return(ctx.GetResult()); }
public override ILexer <ObsoleteFold> Create() { var innerLexer = Concatenation.Create( NewLineLexerFactory.Create(), Repetition.Create( Alternation.Create(SpaceLexerFactory.Create(), HorizontalTabLexerFactory.Create()), 1, int.MaxValue)); return(new ObsoleteFoldLexer(innerLexer)); }
public override ILexer <Host> Create() { var innerLexer = Concatenation.Create( UriHostLexerFactory.Create(), Option.Create( Concatenation.Create( Terminal.Create(@":", StringComparer.Ordinal), PortLexerFactory.Create()))); return(new HostLexer(innerLexer)); }
public override ILexer <ReceivedProtocol> Create() { var innerLexer = Concatenation.Create( Option.Create( Concatenation.Create( ProtocolNameLexerFactory.Create(), Terminal.Create(@"/", StringComparer.Ordinal))), ProtocolVersionLexerFactory.Create()); return(new ReceivedProtocolLexer(innerLexer)); }
public override ILexer <PartialUri> Create() { var innerLexer = Concatenation.Create( RelativePartLexerFactory.Create(), OptionalDelimitedListLexerFactory.Create( Concatenation.Create( Terminal.Create(@"?", StringComparer.Ordinal), QueryLexerFactory.Create()))); return(new PartialUriLexer(innerLexer)); }
public override ILexer <HttpVersion> Create() { var digit = DigitLexerFactory.Create(); var innerLexer = Concatenation.Create( HttpNameLexerFactory.Create(), Terminal.Create(@"/", StringComparer.Ordinal), digit, Terminal.Create(@".", StringComparer.Ordinal), digit); return(new HttpVersionLexer(innerLexer)); }
public override ILexer <LastChunk> Create() { var innerLexer = Concatenation.Create( Repetition.Create( Terminal.Create(@"0", StringComparer.Ordinal), 1, int.MaxValue), Option.Create(ChunkExtensionLexerFactory.Create()), NewLineLexerFactory.Create()); return(new LastChunkLexer(innerLexer)); }
public override ILexer <HeaderField> Create() { var ows = OptionalWhiteSpaceLexerFactory.Create(); var innerLexer = Concatenation.Create( FieldNameLexerFactory.Create(), Terminal.Create(@":", StringComparer.Ordinal), ows, FieldValueLexerFactory.Create(), ows); return(new HeaderFieldLexer(innerLexer)); }
public override ILexer <QuotedPair> Create() { var htab = HorizontalTabLexerFactory.Create(); var sp = SpaceLexerFactory.Create(); var vchar = VisibleCharacterLexerFactory.Create(); var obsText = ObsoleteTextLexerFactory.Create(); var innerLexer = Concatenation.Create( Terminal.Create(@"\", StringComparer.Ordinal), Alternation.Create(htab, sp, vchar, obsText)); return(new QuotedPairLexer(innerLexer)); }
public override ILexer <Authority> Create() { var at = Terminal.Create(@"@", StringComparer.Ordinal); var userinfoseq = Concatenation.Create(UserInformationLexerFactory.Create(), at); var optuserinfo = Option.Create(userinfoseq); var colon = Terminal.Create(@":", StringComparer.Ordinal); var portseq = Concatenation.Create(colon, PortLexerFactory.Create()); var optport = Option.Create(portseq); var innerLexer = Concatenation.Create(optuserinfo, HostLexerFactory.Create(), optport); return(new AuthorityLexer(innerLexer)); }
public override ILexer <AbsolutePath> Create() { var innerLexer = Repetition.Create( Concatenation.Create( Terminal.Create(@"/", StringComparer.Ordinal), Segment.Create()), 1, int.MaxValue); return(new AbsolutePathLexer(innerLexer)); }
public override ILexer <TransferCodingRank> Create() { var ows = OptionalWhiteSpaceLexerFactory.Create(); var innerLexer = Concatenation.Create( ows, Terminal.Create(@";", StringComparer.Ordinal), ows, Terminal.Create(@"q=", StringComparer.OrdinalIgnoreCase), RankLexerFactory.Create()); return(new TransferCodingRankLexer(innerLexer)); }
public override ILexer <ReceivedBy> Create() { var innerLexer = Alternation.Create( Concatenation.Create( UriHostLexerFactory.Create(), Option.Create( Concatenation.Create( Terminal.Create(@":", StringComparer.Ordinal), PortLexerFactory.Create()))), PseudonymLexerFactory.Create()); return(new ReceivedByLexer(innerLexer)); }
public override ILexer <TransferParameter> Create() { var bws = BadWhiteSpaceLexerFactory.Create(); var token = TokenLexerFactory.Create(); var innerLexer = Concatenation.Create( token, bws, Terminal.Create(@"=", StringComparer.Ordinal), bws, Alternation.Create(token, QuotedStringLexerFactory.Create())); return(new TransferParameterLexer(innerLexer)); }
public override ILexer <PathRootless> Create() { var innerLexer = Concatenation.Create( SegmentNonZeroLengthLexerFactory.Create(), Repetition.Create( Concatenation.Create( Terminal.Create(@"/", StringComparer.Ordinal), SegmentLexerFactory.Create()), 0, int.MaxValue)); return(new PathRootlessLexer(innerLexer)); }
public override ILexer <RequestLine> Create() { var sp = SpaceLexerFactory.Create(); var innerLexer = Concatenation.Create( MethodLexerFactory.Create(), sp, RequestTargetLexerFactory.Create(), sp, HttpVersionLexerFactory.Create(), NewLineLexerFactory.Create()); return(new RequestLineLexer(innerLexer)); }
void IExpressionVisitor.Visit(Concatenation expression) { switch (expression.ChildExpressions.Length) { case 2: Concatenate(expression.ChildExpressions, concatenate2Method); break; case 3: Concatenate(expression.ChildExpressions, concatenate3Method); break; case 4: Concatenate(expression.ChildExpressions, concatenate4Method); break; default: ConcatenateArray(expression.ChildExpressions); break; } }
public override ILexer <StatusLine> Create() { var sp = SpaceLexerFactory.Create(); var innerLexer = Concatenation.Create( HttpVersionLexerFactory.Create(), sp, StatusCodeLexerFactory.Create(), sp, ReasonPhraseLexerFactory.Create(), NewLineLexerFactory.Create()); return(new StatusLineLexer(innerLexer)); }
/// <summary> /// Constructor with all parameter /// </summary> /// <param name="field">Field name for filter</param> /// <param name="comparator">Comparator operator</param> /// <param name="value">Value for comparison</param> /// <param name="concatenator">Operator of concatenation with next filter</param> public Filter(string field, Comparison comparator, object value, Concatenation concatenator) : this(field, comparator, value) { Concatenator = concatenator; }