コード例 #1
0
        private void AssertWithHeader(string full, string expected, EmptyVisitor visitor)
        {
            var syntax   = new Parser(Tokenizer.Create()).Parse(full);
            var semantic = new Semantic.SemanticAnalyzer().Analize(syntax);
            var machine  = new Optimize.Optimizer().Optimize(semantic);
            var node     = new NscGenerator().Generate(machine);

            node.Accept(visitor);
            visitor.Result.Should().Be(expected);
        }
コード例 #2
0
        private void AssertGenerated(string transitionSyntax, string expected, EmptyVisitor visitor)
        {
            var header   = "Initial: I FSM:f Actions:acts";
            var syntax   = new Parser(Tokenizer.Create()).Parse(header + transitionSyntax);
            var semantic = new Semantic.SemanticAnalyzer().Analize(syntax);
            var machine  = new Optimize.Optimizer().Optimize(semantic);
            var node     = new NscGenerator().Generate(machine);

            node.Accept(visitor);
            visitor.Result.Should().Be(expected);
        }
コード例 #3
0
        public string Generate(string input)
        {
            var syntax   = new Parser(Tokenizer.Create()).Parse(input);
            var semantic = new Semantic.SemanticAnalyzer().Analize(syntax);
            var machine  = new Optimize.Optimizer().Optimize(semantic);
            var node     = new NscGenerator().Generate(machine);
            var visitor  = new CsharpVisitor();

            node.Accept(visitor);
            return(visitor.Result);
        }
コード例 #4
0
        private static void Compile(string inputFile, string outputFile)
        {
            var input    = File.ReadAllText(inputFile);
            var syntax   = new Parser(Tokenizer.Create()).Parse(input);
            var semantic = new SemanticAnalyzer().Analize(syntax);
            var machine  = new Optimizer().Optimize(semantic);
            var node     = new NscGenerator().Generate(machine);

            var visitor = new CsharpVisitor();

            node.Accept(visitor);

            File.WriteAllText(outputFile, visitor.Result);
        }