コード例 #1
0
    public void TextEquals(string beforePP, string afterPP)
    {
        var expectLexer = new CLexer(afterPP);
        var pp          = new CPreProcessor(new CLexer(beforePP))
                          .DefineCounter();

        while (true)
        {
            var expected = expectLexer.Next();
            var got      = pp.Next();

            Assert.Equal(expected.Kind, got.Kind);
            Assert.Equal(expected.LogicalText, got.LogicalText);
            if (expected.Kind == CTokenType.End)
            {
                break;
            }
        }
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: LanguageDev/Yoakke
    static void Main(string[] args)
    {
        var sourceCode = @"
#define FOO(x, y) x ## y
FOO(L, ""asd"")
";
        var lexer      = new CLexer(sourceCode);
        var pp         = new CPreProcessor(lexer);

        while (true)
        {
            var token = pp.Next();
            if (token.Kind == CTokenType.End)
            {
                break;
            }
            Console.WriteLine(token.LogicalText);
        }
    }