public override ILexer <Unreserved> Create() { var innerLexer = Alternation.Create( AlphaLexerFactory.Create(), DigitLexerFactory.Create(), Terminal.Create(@"-", StringComparer.Ordinal), Terminal.Create(@".", StringComparer.Ordinal), Terminal.Create(@"_", StringComparer.Ordinal), Terminal.Create(@"~", StringComparer.Ordinal)); return(new UnreservedLexer(innerLexer)); }
public void CanReadUppercaseAsciiLetters(string input) { var factory = new AlphaLexerFactory(new ValueRangeLexerFactory(), new AlternativeLexerFactory()); var alphaLexer = factory.Create(); using (var scanner = new TextScanner(new StringTextSource(input))) { var result = alphaLexer.Read(scanner); Assert.NotNull(result); Assert.True(result.Success); Assert.NotNull(result.Element); Assert.Equal(input, result.Element.Text); } }
public override ILexer <Scheme> Create() { var alpha = AlphaLexerFactory.Create(); var digit = DigitLexerFactory.Create(); var innerLexer = Concatenation.Create( alpha, Repetition.Create( Alternation.Create( alpha, digit, Terminal.Create(@"+", StringComparer.Ordinal), Terminal.Create(@"-", StringComparer.Ordinal), Terminal.Create(@".", StringComparer.Ordinal)), 0, int.MaxValue)); return(new SchemeLexer(innerLexer)); }
public override ILexer <TokenCharacter> Create() { var innerLexer = Alternation.Create( Terminal.Create(@"!", StringComparer.Ordinal), Terminal.Create(@"#", StringComparer.Ordinal), Terminal.Create(@"$", StringComparer.Ordinal), Terminal.Create(@"%", StringComparer.Ordinal), Terminal.Create(@"&", StringComparer.Ordinal), Terminal.Create(@"'", StringComparer.Ordinal), Terminal.Create(@"*", StringComparer.Ordinal), Terminal.Create(@"+", StringComparer.Ordinal), Terminal.Create(@"-", StringComparer.Ordinal), Terminal.Create(@".", StringComparer.Ordinal), Terminal.Create(@"^", StringComparer.Ordinal), Terminal.Create(@"_", StringComparer.Ordinal), Terminal.Create(@"`", StringComparer.Ordinal), Terminal.Create(@"|", StringComparer.Ordinal), Terminal.Create(@"~", StringComparer.Ordinal), DigitLexerFactory.Create(), AlphaLexerFactory.Create()); return(new TokenCharacterLexer(innerLexer)); }