Exemplo n.º 1
0
        public override syntax_tree_node BuildTreeInNormalMode(string FileName, string Text, List <string> DefinesList = null)
        {
            Errors.Clear();
            Warnings.Clear();

            /*string[] file_names = new string[1];
             * file_names[0] = FileName;
             *
             * preprocessor2.Build(file_names, Errors, null);*/

            PreprocessorParserHelper preprocessor3 = new PreprocessorParserHelper(Errors, FileName);
            var b = preprocessor3.Parse(Text);

            if (Errors.Count > 0)
            {
                return(null);
            }

            localparserhelper             = new GPPGParserHelper(Errors, Warnings, FileName);
            localparserhelper.DefinesList = DefinesList;
            syntax_tree_node root = localparserhelper.Parse(Text);

            if (Errors.Count > 0)
            {
                return(null);
            }

            if (root != null && root is compilation_unit)
            {
                (root as compilation_unit).file_name = FileName;
            }

            /*if (preprocessor2.CompilerDirectives != null && preprocessor2.CompilerDirectives.Count != 0)
             *  CompilerDirectives.AddRange(preprocessor2.CompilerDirectives);*/

            if (preprocessor3.compilerDirectives != null && preprocessor3.compilerDirectives.Count != 0)
            {
                CompilerDirectives.AddRange(preprocessor3.compilerDirectives);
            }

            return(root);
        }
Exemplo n.º 2
0
        public override syntax_tree_node BuildTreeInNormalMode(string FileName, string Text)
        {
            Errors.Clear();

            /*string[] file_names = new string[1];
            file_names[0] = FileName;

            preprocessor2.Build(file_names, Errors, null);*/

            PreprocessorParserHelper preprocessor3 = new PreprocessorParserHelper(Errors, FileName);
            var b = preprocessor3.Parse(Text);
            
            if (Errors.Count > 0)
                return null;

            localparserhelper = new GPPGParserHelper(Errors, FileName);

            syntax_tree_node root = localparserhelper.Parse(Text);

            if (Errors.Count > 0)
                return null;

            if (root != null && root is compilation_unit)
                (root as compilation_unit).file_name = FileName;

            /*if (preprocessor2.CompilerDirectives != null && preprocessor2.CompilerDirectives.Count != 0)
                CompilerDirectives.AddRange(preprocessor2.CompilerDirectives);*/

            if (preprocessor3.compilerDirectives != null && preprocessor3.compilerDirectives.Count != 0)
                CompilerDirectives.AddRange(preprocessor3.compilerDirectives);

            return root;
        }