Example #1
0
        public static IFunctionStream CreateFunctionStream(LookAheadLangParser parser, string filename, bool suppressMethodSignatures)
        {
            if (filename.ToLower().EndsWith(".js") || filename.ToLower().EndsWith(".ts"))
            return new JSParser(parser);

              return new CCCParser(parser, suppressMethodSignatures);
        }
Example #2
0
        public FileAnalyzer(StreamReader filestream, ICCMNotify callback, object context, bool suppressMethodSignatures, string filename,
                            ParserSwitchBehavior switchBehavior = ParserSwitchBehavior.TraditionalInclude)
        {
            this.buffer = new CharBuffer(filestream.BaseStream.Length);
            this.buffer.ReadEntireStream(filestream);

            var processStream = new StreamReader(buffer.GetBytesMemoryStream());

            // 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;
        }
Example #3
0
        public FileAnalyzer(StreamReader filestream, ICCMNotify callback, object context, bool suppressMethodSignatures, string filename)
        {
            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;
        }
Example #4
0
        public static IFunctionStream CreateFunctionStream(LookAheadLangParser parser, string filename, bool suppressMethodSignatures)
        {
            if (filename.ToLower().EndsWith(".js") || filename.ToLower().EndsWith(".ts"))
            {
                return(new JSParser(parser));
            }

            return(new CCCParser(parser, suppressMethodSignatures));
        }
Example #5
0
        private static bool NextIsCommentBlock(LookAheadLangParser parser)
        {
            if (parser.PeekNextKeyword(0).Equals("/") && (
                    parser.PeekNextKeyword(1).Equals("/") || parser.PeekNextKeyword(1).Equals("*")))
            {
                return(true);
            }

            return(false);
        }
Example #6
0
        public static bool NextIsIfndef(LookAheadLangParser parser)
        {
            if (parser.PeekNextKeyword().Equals("#"))
              {
            string directive = Preprocessor.GetDirective(parser);

            if (directive.Equals("ifndef"))
              return true;
              }

              return false;
        }
Example #7
0
        public BlockAnalyzer(LookAheadLangParser parser, IFunctionStream functionStream = null, OnLocalFunctionDelegate onLocalFunctionDelegate = null)
        {
            this.parser = parser;
            this.conditionalsWithExpressions = new List <string>(
                new string[] { "if", "while", "foreach", "for", "else if", });

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

            this.functionStream          = functionStream;
            this.onLocalFunctionDelegate = onLocalFunctionDelegate;
        }
Example #8
0
        public static bool NextIsEndif(LookAheadLangParser parser)
        {
            if (parser.PeekNextKeyword().Equals("#"))
              {
            if (parser.PeekNextKeyword(1).Equals("endif") ||
            parser.PeekNextKeyword(1).Equals("end"))
            {
              return true;
            }
              }

              return false;
        }
Example #9
0
        public static bool NextIsEndif(LookAheadLangParser parser)
        {
            if (parser.PeekNextKeyword().Equals("#"))
            {
                if (parser.PeekNextKeyword(1).Equals("endif") ||
                    parser.PeekNextKeyword(1).Equals("end"))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #10
0
        public void ConsumeIfDef(LookAheadLangParser parser)
        {
            Debug.Assert(Preprocessor.NextIsIfdef(parser));

            while (!(parser.PeekNextKeyword().Equals("if") ||
                     parser.PeekNextKeyword().Equals("ifdef") ||
                     parser.PeekNextKeyword().Equals("def")))
            {
                ConumseNextKeyWordSpaceOutput();
            }

            ConumseNextKeyWordSpaceOutput();
        }
Example #11
0
        public static bool NextIsElse(LookAheadLangParser parser)
        {
            if (parser.PeekNextKeyword().Equals("#"))
            {
                string directive = Preprocessor.GetDirective(parser);

                if (directive.Equals("else"))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #12
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;
        }
Example #13
0
        private static string GetDirective(LookAheadLangParser parser)
        {
            if (parser.PeekNextKeyword().Equals("#"))
            {
                int offset = 1;

                while (parser.PeekNextKeyword(offset).Equals(" "))
                {
                    offset++;
                }

                return(parser.PeekNextKeyword(offset));
            }

            throw new UnknownStructureException("Internal pre processor error.");
        }
Example #14
0
        public void ConsumeIfndef(LookAheadLangParser parser)
        {
            Debug.Assert(Preprocessor.NextIsIfndef(parser));

            while (true)
            {
                if (parser.PeekNextKeyword().Equals("ifndef"))
                {
                    break;
                }

                ConumseNextKeyWordSpaceOutput();
            }

            ConumseNextKeyWordSpaceOutput();
        }
Example #15
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;
        }
Example #16
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;
        }
Example #17
0
        public void ConsumeIfndef(LookAheadLangParser parser)
        {
            Debug.Assert(Preprocessor.NextIsIfndef(parser));

              while (true)
              {
            if (parser.PeekNextKeyword().Equals("ifndef"))
            {
              break;
            }

            ConumseNextKeyWordSpaceOutput();
              }

              ConumseNextKeyWordSpaceOutput();
        }
Example #18
0
        public Preprocessor(StreamReader inputStream)
        {
            LookAheadTokenParser tokenParser = new LookAheadTokenParser(inputStream, Preprocessor.tokens, false);

              this.parser = new LookAheadLangParser(tokenParser);
        }
Example #19
0
        private static string GetDirective(LookAheadLangParser parser)
        {
            if (parser.PeekNextKeyword().Equals("#"))
              {
            int offset = 1;

            while (parser.PeekNextKeyword(offset).Equals(" "))
              offset++;

            return parser.PeekNextKeyword(offset);
              }

              throw new UnknownStructureException("Internal pre processor error.");
        }
Example #20
0
        public Preprocessor(StreamReader inputStream)
        {
            LookAheadTokenParser tokenParser = new LookAheadTokenParser(inputStream, Preprocessor.tokens, false);

            this.parser = new LookAheadLangParser(tokenParser);
        }
Example #21
0
        private static bool NextIsCommentBlock(LookAheadLangParser parser)
        {
            if (parser.PeekNextKeyword(0).Equals("/") && (
              parser.PeekNextKeyword(1).Equals("/") || parser.PeekNextKeyword(1).Equals("*")))
            return true;

              return false;
        }
Example #22
0
 public JSParser(LookAheadLangParser parser)
 {
     this.parser = parser;
 }
Example #23
0
        public void ConsumeIfDef(LookAheadLangParser parser)
        {
            Debug.Assert(Preprocessor.NextIsIfdef(parser));

              while (!(parser.PeekNextKeyword().Equals("if") ||
              parser.PeekNextKeyword().Equals("ifdef") ||
              parser.PeekNextKeyword().Equals("def")))
              {
            ConumseNextKeyWordSpaceOutput();
              }

              ConumseNextKeyWordSpaceOutput();
        }
Example #24
0
 public TestContext(LookAheadLangParser parser, CCCParser ccc)
 {
     this.parser = parser;
     this.ccc = ccc;
 }
Example #25
0
 public JSParser(LookAheadLangParser parser)
 {
     this.parser = parser;
 }
Example #26
0
 public CCCParser(LookAheadLangParser parser, bool suppressSignature)
 {
     this.parser = parser;
       this.suppressSignature = suppressSignature;
 }
Example #27
0
 public CCCParser(LookAheadLangParser parser, bool suppressSignature)
 {
     this.parser            = parser;
     this.suppressSignature = suppressSignature;
 }