Package dk.brics.string.grammar

Examples of dk.brics.string.grammar.Nonterminal


        MLFA mlfa = gm.convert();

        propagateTaint(r);

        for (Node n : nodes) {
            Nonterminal nt = f2g.getNonterminal(n);
            MLFAStatePair sp = gm.getMLFAStatePair(nt);
            if (nt.isTaint()) {
                sp.setTaint(true);
            }
        }
        log.debug(mlfa.toString());

        // Make map
        map = new HashMap<ValueBox, MLFAStatePair>();
        for (ValueBox box : hotspots) {
            Node n = m3.get(m2.get(m1.get(box)));
            if (n != null) {
                Nonterminal nt = f2g.getNonterminal(n);
                MLFAStatePair sp = gm.getMLFAStatePair(nt);
                map.put(box, sp);
            }
        }
        tostring_map = new HashMap<SootClass, MLFAStatePair>();
        Map<SootClass, StringStatement> tostring_hotspot_map = jt.getToStringHotspotMap();
        for (Map.Entry<SootClass, StringStatement> tse : tostring_hotspot_map.entrySet()) {
            SootClass tsc = tse.getKey();
            StringStatement ss = tse.getValue();
            Node n = m3.get(m2.get(ss));
            if (n != null) {
                Nonterminal nt = f2g.getNonterminal(n);
                MLFAStatePair sp = gm.getMLFAStatePair(nt);
                tostring_map.put(tsc, sp);
            }
        }
        sourcefile_map = jt.getSourceFileMap();
View Full Code Here


     */
    public Grammar convert() {
        final Grammar r = new Grammar();
        node2nt = new ArrayList<Nonterminal>();
        for (Node node : g.getNodes()) {
            Nonterminal n = r.addNonterminal();
            n.setTaint(node.isTaint());
            node2nt.add(n);
        }
        g.visitNodes(new NodeVisitor() {

            public void visitAssignmentNode(AssignmentNode n) {
                for (Node m : n.getArg().getDefs()) {
                    r.addUnitProduction(getNonterminal(n), getNonterminal(m));
                }
            }

            public void visitConcatenationNode(ConcatenationNode n) {
                for (Node m1 : n.getArg1().getDefs()) {
                    for (Node m2 : n.getArg2().getDefs()) {
                        r.addPairProduction(getNonterminal(n), getNonterminal(m1), getNonterminal(m2));
                    }
                }
            }

            public void visitInitializationNode(InitializationNode n) {
                r.addAutomatonProduction(getNonterminal(n), n.getReg());
            }

            public void visitUnaryNode(UnaryNode n) {
                for (Node m : n.getArg().getDefs()) {
                    r.addUnaryProduction(getNonterminal(n), n.getOp(), getNonterminal(m));
                }
            }

            public void visitBinaryNode(BinaryNode n) {
                for (Node m1 : n.getArg1().getDefs()) {
                    for (Node m2 : n.getArg2().getDefs()) {
                        r.addBinaryProduction(getNonterminal(n), n.getOp(), getNonterminal(m1), getNonterminal(m2));
                    }
                }
            }
        });
        return r;
View Full Code Here

TOP

Related Classes of dk.brics.string.grammar.Nonterminal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.