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 <StatusLine> Create() { var sp = SpaceLexerFactory.Create(); var innerLexer = Concatenation.Create( HttpVersionLexerFactory.Create(), sp, StatusCodeLexerFactory.Create(), sp, ReasonPhraseLexerFactory.Create(), NewLineLexerFactory.Create()); return(new StatusLineLexer(innerLexer)); }
public override ILexer <ReasonPhrase> Create() { var innerLexer = Repetition.Create( Alternation.Create( HorizontalTabLexerFactory.Create(), SpaceLexerFactory.Create(), VisibleCharacterLexerFactory.Create(), ObsoleteTextLexerFactory.Create()), 0, int.MaxValue); return(new ReasonPhraseLexer(innerLexer)); }
public void ReadSuccess(string input) { var factory = new SpaceLexerFactory(new TerminalLexerFactory()); var spaceLexer = factory.Create(); using (var scanner = new TextScanner(new StringTextSource(input))) { var result = spaceLexer.Read(scanner); Assert.NotNull(result); Assert.True(result.Success); Assert.NotNull(result.Element); Assert.Equal(input, result.Element.Text); } }
public void ReadSuccess(string input) { // General var terminalLexerFactory = new TerminalLexerFactory(); var alternativeLexerFactory = new AlternativeLexerFactory(); var sequenceLexerFactory = new ConcatenationLexerFactory(); var repetitionLexerFactory = new RepetitionLexerFactory(); // SP var spaceLexerFactory = new SpaceLexerFactory(terminalLexerFactory); // HTAB var horizontalTabLexerFactory = new HorizontalTabLexerFactory(terminalLexerFactory); // WSP var whiteSpaceLexerFactory = new WhiteSpaceLexerFactory( spaceLexerFactory, horizontalTabLexerFactory, alternativeLexerFactory); // CR var carriageReturnLexerFactory = new CarriageReturnLexerFactory(terminalLexerFactory); // LF var lineFeedLexerFactory = new LineFeedLexerFactory(terminalLexerFactory); // CRLF var endOfLineLexerFactory = new EndOfLineLexerFactory( carriageReturnLexerFactory, lineFeedLexerFactory, sequenceLexerFactory); // LWSP var linearWhiteSpaceLexerFactory = new LinearWhiteSpaceLexerFactory( whiteSpaceLexerFactory, endOfLineLexerFactory, sequenceLexerFactory, alternativeLexerFactory, repetitionLexerFactory); var linearWhiteSpaceLexer = linearWhiteSpaceLexerFactory.Create(); using (var scanner = new TextScanner(new StringTextSource(input))) { var result = linearWhiteSpaceLexer.Read(scanner); Assert.NotNull(result); Assert.True(result.Success); Assert.NotNull(result.Element); Assert.Equal(input, result.Element.Text); } }
public void ReadSuccess(string input) { var terminalLexerFactory = new TerminalLexerFactory(); var spaceLexerFactory = new SpaceLexerFactory(terminalLexerFactory); var horizontalTabLexerFactory = new HorizontalTabLexerFactory(terminalLexerFactory); var alternativeLexerFactory = new AlternativeLexerFactory(); var whiteSpaceLexerFactory = new WhiteSpaceLexerFactory(spaceLexerFactory, horizontalTabLexerFactory, alternativeLexerFactory); var whiteSpaceLexer = whiteSpaceLexerFactory.Create(); using (var scanner = new TextScanner(new StringTextSource(input))) { var result = whiteSpaceLexer.Read(scanner); Assert.NotNull(result); Assert.True(result.Success); Assert.NotNull(result.Element); Assert.Equal(input, result.Element.Text); } }