Package de.fosd.typechef.featureexpr

Examples of de.fosd.typechef.featureexpr.FeatureExpr


                FeatureExprLib.l().createDefinedExternal(flag).not()).isContradiction(featureModel);
    }

    private FeatureExpr parse_definedExpr(boolean referToExternalDefinitionsOnly)
            throws IOException, LexerException {
        FeatureExpr lhs;
        Token la = source_token_nonwhite();
        boolean paren = false;
        if (la.getType() == '(') {
            paren = true;
            la = source_token_nonwhite();
View Full Code Here


                        case PP_IF:
                            push_state();
                            expr_token = null;
                            if (isParentActive()) {
                                FeatureExpr localFeatureExpr = parse_featureExpr();
                                state.putLocalFeature(localFeatureExpr, macros);
                                tok = expr_token(true); /* unget */
                                if (tok.getType() != NL)
                                    source_skipline(isParentActive());
                            } else {
                                state.putLocalFeature(FeatureExprLib.False(), macros);
                                source_skipline(false);
                            }


                            return ifdefPrinter.startIf(tok, isParentActive(), state);

                        // break;

                        case PP_ELIF:
                            if (state.sawElse()) {
                                error(tok, "#elif after #" + "else");
                                return source_skipline(false);
                            } else {
                                expr_token = null;
                                // parse with parents state to allow macro expansion
                                State oldState = state;
                                state = state.parent;
                                FeatureExpr localFeaturExpr = isActive() ? parse_featureExpr() : FeatureExprLib.False();
                                state = oldState;
                                state.processElIf();
                                state.putLocalFeature(localFeaturExpr, macros);
                                tok = expr_token(true); /* unget */

                                if (tok.getType() != NL)
                                    source_skipline(isParentActive());

                                return ifdefPrinter.startElIf(tok, isParentActive(),
                                        state);

                            }
                            // break;

                        case PP_ELSE:
                            if (state.sawElse()) {
                                error(tok, "#" + "else after #" + "else");
                                return source_skipline(false);
                            } else {
                                state.setSawElse();
                                source_skipline(warnings.contains(Warning.ENDIF_LABELS));

                                return ifdefPrinter.startElIf(tok, isParentActive(),
                                        state);
                            }
                            // break;

                        case PP_IFDEF:
                            push_state();
                            tok = source_token_nonwhite();
                            // System.out.println("ifdef " + tok);
                            if (tok.getType() != IDENTIFIER) {
                                error(tok, "Expected identifier, not " + tok.getText());
                                return source_skipline(false);
                            } else {
                                FeatureExpr localFeatureExpr2 = parse_ifdefExpr(tok
                                        .getText());
                                state.putLocalFeature(
                                        isParentActive() ? localFeatureExpr2
                                                : FeatureExprLib.False(), macros);
                                // return

                                if (tok.getType() != NL)
                                    source_skipline(isParentActive());

                                return ifdefPrinter.startIf(tok, isParentActive(),
                                        state);
                            }
                            // break;

                        case PP_IFNDEF:
                            push_state();
                            tok = source_token_nonwhite();
                            if (tok.getType() != IDENTIFIER) {
                                error(tok, "Expected identifier, not " + tok.getText());
                                return source_skipline(false);
                            } else {
                                FeatureExpr localFeatureExpr3 = parse_ifndefExpr(tok
                                        .getText());
                                state.putLocalFeature(
                                        isParentActive() ? localFeatureExpr3
                                                : FeatureExprLib.False(), macros);
                                if (tok.getType() != NL)
View Full Code Here

                smallFeatureModel = FeatureExprLib.featureModelFactory().createFromDimacsFilePrefix(g.getOptarg(),"CONFIG_");
            else
                smallFeatureModel = FeatureExprLib.featureModelFactory().createFromDimacsFilePrefix(g.getOptarg(),"");
        } else if (c == FM_FEXPR) {     //--featureModelFExpr
            checkFileExists(g.getOptarg());
            FeatureExpr f = new FeatureExprParserJava(FeatureExprLib.l()).parseFile(g.getOptarg());
            if (smallFeatureModel == null)
                smallFeatureModel = FeatureExprLib.featureModelFactory().create(f);
            else smallFeatureModel = smallFeatureModel.and(f);
//        } else if (c == FM_CLASS) {//--featureModelClass
//            try {
//                FeatureModelFactory factory = (FeatureModelFactory) Class.forName(g.getOptarg()).newInstance();
//                smallFeatureModel = factory.createFeatureModel();
//            } catch (Exception e) {
//                throw new OptionException("cannot instantiate feature model: " + e.getMessage());
//            }
        } else if (c == FM_TSDIMACS) {
            checkFileExists(g.getOptarg());
            fullFeatureModel = FeatureExprLib.featureModelFactory().createFromDimacsFilePrefix(g.getOptarg(),"CONFIG_");
        } else if (c == FM_PARTIALCONFIG) {
            checkFileExists(g.getOptarg());
            if (partialConfig != null)
                throw new OptionException("cannot load a second partial configuration");
            partialConfig = PartialConfigurationParser$.MODULE$.load(g.getOptarg());
            FeatureExpr f = partialConfig.getFeatureExpr();
            if (fullFeatureModel == null)
                fullFeatureModel = FeatureExprLib.featureModelFactory().empty();

            for (String featureName : partialConfig.getDefinedFeatures())
                fullFeatureModel = fullFeatureModel.assumeTrue(featureName);
View Full Code Here

        }

        private Stack<IfdefBlock> stack = new Stack<IfdefBlock>();

        public Token startIf(Token tok, boolean parentActive, State state) {
            FeatureExpr localCondition = state.getLocalFeatureExpr();
            boolean visible = isIfVisible(parentActive, state);

            stack.push(new IfdefBlock(visible));
            if (visible)
                return OutputHelper.if_token(tok.getLine(), localCondition);
View Full Code Here

        }

        // skip output of ifdef 0 and ifdef 1
        private boolean isIfVisible(boolean parentActive, State state) {
            FeatureExpr expr = state.getLocalFeatureExpr();
            FeatureExpr fullPresenceCondition = state.getFullPresenceCondition();
            FeatureExpr parentPc = state.parent.getFullPresenceCondition();
            boolean visible = parentActive;
            if (visible &&
                    (expr.isContradiction(featureModel) ||
                            expr.isTautology(featureModel) ||
                            fullPresenceCondition.isContradiction(featureModel) ||
                            fullPresenceCondition.isTautology(featureModel) ||
                            parentPc.implies(expr).isTautology(featureModel) ||
                            parentPc.implies(expr.not()).isTautology(featureModel)))
                visible = false;
            return visible;
        }
View Full Code Here

                return OutputHelper.emptyLine(tok.getLine(), tok.getColumn());
        }

        public Token startElIf(Token tok, boolean parentActive,
                               State state) {
            FeatureExpr localCondition = state.getLocalFeatureExpr();

            boolean wasVisible = stack.pop().visible;
            boolean isVisible = isIfVisible(parentActive, state);
            stack.push(new IfdefBlock(isVisible));
View Full Code Here

TOP

Related Classes of de.fosd.typechef.featureexpr.FeatureExpr

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.