Ejemplo n.º 1
0
            public virtual Parser build()
            {
                Parser parser = new Parser();

                // decide what to show
                AAction.displaySemi  = false;
                AAction.displayStack = false;  // false is default

                // action used for namespaces, classes, and functions
                PushStack push = new PushStack(repo);

                // capture namespace info
                DetectNamespace detectNS = new DetectNamespace();

                detectNS.add(push);
                parser.add(detectNS);

                // capture class info
                DetectClass detectCl = new DetectClass();

                detectCl.add(push);
                parser.add(detectCl);

                // capture function info
                DetectFunction detectFN = new DetectFunction();

                detectFN.add(push);
                parser.add(detectFN);

                // handle entering anonymous scopes, e.g., if, while, etc.
                DetectAnonymousScope anon = new DetectAnonymousScope();

                anon.add(push);
                parser.add(anon);

                // show public declarations
                DetectPublicDeclar pubDec = new DetectPublicDeclar();
                SaveDeclar         print  = new SaveDeclar(repo);

                pubDec.add(print);
                parser.add(pubDec);

                // handle leaving scopes
                DetectLeavingScope leave = new DetectLeavingScope();
                PopStack           pop   = new PopStack(repo);

                leave.add(pop);
                parser.add(leave);

                // parser configured
                return(parser);
            }
Ejemplo n.º 2
0
        public virtual RulesBasedParser build()
        {
            RulesBasedParser rulesBasedParser = new RulesBasedParser();

            // decide what to show
            AAction.displaySemi  = false;
            AAction.displayStack = false;              // false is default

            // action used for namespaces, classes, and functions
            PushStack push = new PushStack(Repo);

            // capture namespace info
            DetectNamespace detectNS = new DetectNamespace();

            detectNS.add(push);
            rulesBasedParser.add(detectNS);

            // capture class info
            DetectClass detectCl = new DetectClass();

            detectCl.add(push);
            rulesBasedParser.add(detectCl);

            // capture function info
            DetectFunction detectFN = new DetectFunction(Repo);

            detectFN.add(push);
            rulesBasedParser.add(detectFN);

            // handle entering anonymous scopes, e.g., if, while, etc.
            DetectAnonymousScope anon = new DetectAnonymousScope();

            anon.add(push);
            rulesBasedParser.add(anon);

            // handle leaving scopes
            DetectLeavingScope leave = new DetectLeavingScope();
            PopStack           pop   = new PopStack(Repo);

            leave.add(pop);
            rulesBasedParser.add(leave);

            // save class member variables
            var detectMembers  = new DetectMemberVariable(Repo);
            var addClassMember = new AddClassMember(Repo);

            detectMembers.add(addClassMember);
            rulesBasedParser.add(detectMembers);

            // rulesBasedParser configured
            return(rulesBasedParser);
        }