Ejemplo n.º 1
0
        public BlockAnalyzer(LookAheadLangParser parser, IFunctionStream functionStream = null, OnLocalFunctionDelegate onLocalFunctionDelegate = null,
            ParserSwitchBehavior switchBehavior = ParserSwitchBehavior.TraditionalInclude)
        {
            this.parser = parser;
              this.conditionalsWithExpressions = new List<string>(
            new string[] { "if", "while", "foreach", "for", "else if", });

              this.branchPointKeywords = new List<string>(new string[] { "catch" });

              if (switchBehavior == ParserSwitchBehavior.TraditionalInclude)
            this.branchPointKeywords.Add("case");

              this.functionStream = functionStream;
              this.onLocalFunctionDelegate = onLocalFunctionDelegate;
        }
Ejemplo n.º 2
0
        public BlockAnalyzer(LookAheadLangParser parser, IFunctionStream functionStream = null, OnLocalFunctionDelegate onLocalFunctionDelegate = null,
                             ParserSwitchBehavior switchBehavior = ParserSwitchBehavior.TraditionalInclude)
        {
            this.parser = parser;
            this.conditionalsWithExpressions = new List <string>(
                new string[] { "if", "while", "foreach", "for", "else if", });

            this.branchPointKeywords = new List <string>(new string[] { "catch" });

            if (switchBehavior == ParserSwitchBehavior.TraditionalInclude)
            {
                this.branchPointKeywords.Add("case");
            }

            this.functionStream          = functionStream;
            this.onLocalFunctionDelegate = onLocalFunctionDelegate;
        }
Ejemplo n.º 3
0
        private void ParseSwitchStatementBehavior(XmlDocument doc)
        {
            XmlElement recursive = (XmlElement)doc.SelectSingleNode("/ccm/switchStatementBehavior");

            if (null != recursive)
            {
                string setting = recursive.InnerText;

                if (setting.Equals("TraditionalInclude", StringComparison.InvariantCultureIgnoreCase))
                {
                    switchBehavior = ParserSwitchBehavior.TraditionalInclude;
                }
                else if (setting.Equals("IgnoreCases", StringComparison.InvariantCultureIgnoreCase))
                {
                    switchBehavior = ParserSwitchBehavior.IgnoreCases;
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Unknown switchStatementBehavior: {0}", setting));
                }
            }
        }
Ejemplo n.º 4
0
        public FileAnalyzer(StreamReader filestream, ICCMNotify callback, object context, bool suppressMethodSignatures, string filename,
            ParserSwitchBehavior switchBehavior = ParserSwitchBehavior.TraditionalInclude)
        {
            this.buffer = new char[filestream.BaseStream.Length];
              filestream.Read(this.buffer, 0, this.buffer.Length);

              var processStream = new StreamReader(new MemoryStream(Encoding.Default.GetBytes(this.buffer)));

              // run through preprocessor before setting up parser...
              Preprocessor preprocessor = new Preprocessor(processStream);
              StreamReader stream = preprocessor.Process();

              // this construct should be fixed and support OCP
              if (filename.ToLower().EndsWith(".js") || filename.ToLower().EndsWith(".ts"))
            this.parser = LookAheadLangParser.CreateJavascriptParser(stream);
              else
            this.parser = LookAheadLangParser.CreateCppParser(stream);

              this.callback = callback;
              this.context = context;
              this.suppressMethodSignatures = suppressMethodSignatures;
              this.filename = filename;
              this.switchBehavior = switchBehavior;
        }
Ejemplo n.º 5
0
        private void ParseSwitchStatementBehavior(XmlDocument doc)
        {
            XmlElement recursive = (XmlElement)doc.SelectSingleNode("/ccm/switchStatementBehavior");

              if (null != recursive)
              {
            string setting = recursive.InnerText;

            if (setting.Equals("TraditionalInclude", StringComparison.InvariantCultureIgnoreCase))
              this.switchBehavior = ParserSwitchBehavior.TraditionalInclude;
            else if (setting.Equals("IgnoreCases", StringComparison.InvariantCultureIgnoreCase))
              this.switchBehavior = ParserSwitchBehavior.IgnoreCases;
            else
              throw new InvalidOperationException(string.Format("Unknown switchStatementBehavior: {0}", setting));
              }
        }