示例#1
0
        public DependencyPass.DependencyTracker GetDemoTracker2(ProtoCore.Core core)
        {
            Associative.Scanner s = new Associative.Scanner(@"..\..\Scripts\expr.ds");
            Associative.Parser p = new Associative.Parser(s, core);
            p.Parse();

            CodeBlockNode code = p.codeblock as CodeBlockNode;

            DependencyTracker tempTracker = new DependencyTracker();
            Dictionary<string, List<Node>> names = new Dictionary<string, List<Node>>();
            code.ConsolidateNames(ref(names));
            tempTracker.GenerateDependencyGraph(code.Body);
            return tempTracker;
        }
示例#2
0
        public DependencyPass.DependencyTracker GetDemoTracker2(ProtoCore.Core core)
        {
            Associative.Scanner s = new Associative.Scanner(@"..\..\Scripts\expr.ds");
            Associative.Parser  p = new Associative.Parser(s, core);
            p.Parse();

            CodeBlockNode code = p.codeblock as CodeBlockNode;

            DependencyTracker tempTracker           = new DependencyTracker();
            Dictionary <string, List <Node> > names = new Dictionary <string, List <Node> >();

            code.ConsolidateNames(ref (names));
            tempTracker.GenerateDependencyGraph(code.Body);
            return(tempTracker);
        }
示例#3
0
        public DependencyPass.DependencyTracker GetDemoTracker3(out ProtoCore.DSASM.SymbolTable symbols, string pathFilename, ProtoCore.Core core)
        {
            Associative.Scanner s = new Associative.Scanner(pathFilename);
            Associative.Parser p = new Associative.Parser(s, core); 
            p.Parse();
            CodeBlockNode code = p.codeblock as CodeBlockNode;
            symbols = code.symbols;
            
            DependencyTracker tempTracker = new DependencyTracker();

#if TEST_DIRECT
            foreach (Node node in code.Body)
            {
                tempTracker.AllNodes.Add(node);
            }
#else
            Dictionary<string, List<Node>> names = new Dictionary<string, List<Node>>();
            code.ConsolidateNames(ref(names));
            tempTracker.GenerateDependencyGraph(code.Body);
#endif
            return tempTracker;
        }
示例#4
0
        public DependencyPass.DependencyTracker GetDemoTracker3(out ProtoCore.DSASM.SymbolTable symbols, string pathFilename, ProtoCore.Core core)
        {
            Associative.Scanner s = new Associative.Scanner(pathFilename);
            Associative.Parser  p = new Associative.Parser(s, core);
            p.Parse();
            CodeBlockNode code = p.codeblock as CodeBlockNode;

            symbols = code.symbols;

            DependencyTracker tempTracker = new DependencyTracker();

#if TEST_DIRECT
            foreach (Node node in code.Body)
            {
                tempTracker.AllNodes.Add(node);
            }
#else
            Dictionary <string, List <Node> > names = new Dictionary <string, List <Node> >();
            code.ConsolidateNames(ref (names));
            tempTracker.GenerateDependencyGraph(code.Body);
#endif
            return(tempTracker);
        }
示例#5
0
文件: Parser.cs 项目: zjloscar/Dynamo
        private void ParseLanguageBlockNode(LanguageBlockNode langblock)
        {
            if (!core.langverify.Verify(langblock.codeblock))
            {
                return;
            }

            ProtoCore.ParserBase   parser    = null;
            System.IO.MemoryStream memstream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(langblock.codeblock.body));

            if (langblock.codeblock.language == ProtoCore.Language.kImperative)
            {
                parser = new Imperative.Parser(new Imperative.Scanner(memstream), core);
            }
            else if (langblock.codeblock.language == ProtoCore.Language.kAssociative)
            {
                parser = new Associative.Parser(new Associative.Scanner(memstream), core);
            }

            try
            {
                parser.errorStream = new System.IO.StringWriter();
                parser.Parse();

                if (parser.errorStream.ToString() != String.Empty)
                {
                    core.BuildStatus.LogSyntaxError(parser.errorStream.ToString());
                }
                core.BuildStatus.errorCount += parser.errorCount;

                langblock.codeBlockNode = parser.codeblock;
            }
            catch (ProtoCore.BuildHaltException e)
            {
                System.Console.WriteLine(e.errorMsg);
            }
        }
示例#6
0
        private void ParseLanguageBlockNode(LanguageBlockNode langblock)
        {
            if (!core.langverify.Verify(langblock.codeblock))
            {
            return;
            }

            ProtoCore.ParserBase parser = null;
            System.IO.MemoryStream memstream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(langblock.codeblock.body));

            if (langblock.codeblock.language ==  ProtoCore.Language.kImperative)
            {
            parser = new Imperative.Parser(new Imperative.Scanner(memstream), core);
            }
            else if (langblock.codeblock.language == ProtoCore.Language.kAssociative)
            {
            parser = new Associative.Parser(new Associative.Scanner(memstream), core);
            }

            try
            {
            parser.errorStream = new System.IO.StringWriter();
            parser.Parse();

            if (parser.errorStream.ToString() != String.Empty)
                core.BuildStatus.LogSyntaxError(parser.errorStream.ToString());
            core.BuildStatus.errorCount += parser.errorCount;

            langblock.codeBlockNode = parser.codeblock;
            }
            catch (ProtoCore.BuildHaltException e)
            {
            System.Console.WriteLine(e.errorMsg);
            }
        }