Package org.sablecc.sablecc.lrautomaton

Examples of org.sablecc.sablecc.lrautomaton.Token


            MLrStateSingleton mLrStateSingleton = mParser
                    .newLrStateSingleton(state.getName());

            for (Entry<Token, LRState> entry : state.getTokenTransitions()
                    .entrySet()) {
                Token token = entry.getKey();
                LRState target = entry.getValue();

                if (token.getName().equals("$end")) {
                    mLrStateSingleton.newEndTokenLrTransitionTarget(target
                            .getName());
                }
                else {
                    MatchedToken matchedToken = context.getMatchedToken(token
                            .getName());
                    String element_CamelCaseType;
                    if (matchedToken instanceof NameToken) {
                        NameToken nameToken = (NameToken) matchedToken;
                        element_CamelCaseType = nameToken.get_CamelCaseName();
                    }
                    else {
                        AnonymousToken anonymousToken = (AnonymousToken) matchedToken;

                        element_CamelCaseType = ""
                                + anonymousToken.get_CamelCaseName();
                    }

                    mLrStateSingleton.newNormalTokenLrTransitionTarget(
                            element_CamelCaseType, target.getName());
                }
            }

            for (Entry<Production, LRState> entry : state
                    .getProductionTransitions().entrySet()) {
                Production production = entry.getKey();
                LRState target = entry.getValue();

                String production_CamelCaseName = to_CamelCase(production
                        .getName());
                mLrStateSingleton.newProductionLrTransitionTarget(
                        production_CamelCaseName, target.getName());
            }

            Map<Integer, MDistance> distanceMap = new LinkedHashMap<Integer, MDistance>();
            boolean isLr1OrMore = false;
            for (Action action : state.getActions()) {
                int maxLookahead = action.getMaxLookahead();
                while (maxLookahead > distanceMap.size() - 1) {
                    int distance = distanceMap.size();
                    distanceMap.put(distance, mLrStateSingleton.newDistance(""
                            + distance));
                }

                MDistance mDistance = distanceMap.get(maxLookahead);
                MAction mAction = mDistance.newAction();
                if (maxLookahead > 0) {
                    isLr1OrMore = true;
                    for (Entry<Integer, Set<Item>> entry : action
                            .getDistanceToItemSetMap().entrySet()) {
                        String ahead = "" + entry.getKey();
                        Set<Item> items = entry.getValue();
                        Set<Token> tokens = new LinkedHashSet<Token>();
                        for (Item item : items) {
                            tokens.add(item.getTokenElement().getToken());
                        }

                        if (tokens.size() == 0) {
                            mAction.newFalseGroup();
                        }
                        else {
                            MNormalGroup mNormalGroup = mAction
                                    .newNormalGroup();

                            for (Token token : tokens) {
                                if (token.getName().equals("$end")) {
                                    mNormalGroup.newEndCondition(ahead);
                                }
                                else {
                                    MatchedToken matchedToken = context
                                            .getMatchedToken(token.getName());
                                    String element_CamelCaseType;
                                    if (matchedToken instanceof NameToken) {
                                        NameToken nameToken = (NameToken) matchedToken;
                                        element_CamelCaseType = nameToken
                                                .get_CamelCaseName();
View Full Code Here

TOP

Related Classes of org.sablecc.sablecc.lrautomaton.Token

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.