示例#1
0
        public void TestCodeGeneration()
        {
            string content = File.ReadAllText(@"D:\Temp\input.lsp");

            SemanticAnalyzer an = new SemanticAnalyzer();

            var tokens = Lexer.ProcessString(content);

            var values = Parser.ProcessTokens(tokens);

            an.CreateSymbolTable(values);

            an.DeriveTypes();

            an.ValidateFuncCalls();

            CodeGenerator cg = new CodeGenerator(an.FuncTable);
            cg.GenerateCFunctions();
            cg.WriteCFunctionsToFile("main.c");
        }
示例#2
0
        public void TestCondCodeGeneration()
        {
            string content = "(defun f (x) (cond   ((< x 5) 7)   ((> x 7) 13)   (T (cond (( < x 1) 9) (T 123)))))";

            SemanticAnalyzer an = new SemanticAnalyzer();

            var tokens = Lexer.ProcessString(content);

            var values = Parser.ProcessTokens(tokens);

            an.CreateSymbolTable(values);

            an.DeriveTypes();

            an.ValidateFuncCalls();

            CodeGenerator cg = new CodeGenerator(an.FuncTable);
            cg.GenerateCFunctions();
            cg.WriteCFunctionsToFile("main.c");
        }