Package org.sodbeans.compiler.api

Examples of org.sodbeans.compiler.api.CompilerTokenId


        try {
            while ((line = buff.readLine()) != null) {
                String[] splLine = line.split("=");
                String name = splLine[0];
                int tok = Integer.parseInt(splLine[1].trim());
                CompilerTokenId id;
                String tokenCategory = tokenTypes.get(name);
                if (tokenCategory != null) {
                    //if the value exists, put it in the correct category
                    id = new CompilerTokenId(name, tokenCategory, tok);
                } else {
                    //if we don't recognize the token, consider it to a separator
                    id = new CompilerTokenId(name, "separator", tok);
                }
                //add it into the vector of tokens
                tokens.add(id);
            }
        } catch (IOException ex) {
View Full Code Here


        Document document = hierarchy.getComponent().getDocument();
        TokenHierarchy<Document> hi = TokenHierarchy.get(document);
        TokenSequence<CompilerTokenId> ts = (TokenSequence<CompilerTokenId>) hi.tokenSequence();

        int actionStack = 0;
        CompilerTokenId actionStart = null;
        int actionOffset = -1;
        int useOffset = -1;
        int endUseOffset = -1;
       
        FoldType type = null;
        int start = 0;
        int offset = 0;
        while (ts.moveNext()) {
            offset = ts.offset();
            Token<CompilerTokenId> token = ts.token();
            CompilerTokenId id = token.id();
            if (id.name().equals(CompilerTokenId.COMMENTS)) {
                start = offset;
                try {
                    operation.addToHierarchy(
                            COMMENT_FOLD_TYPE,
                            COMMENT_FOLD_TYPE.toString(),
                            false,
                            start,
                            offset + token.length(),
                            0,
                            0,
                            hierarchy,
                            transaction);
                } catch (BadLocationException ex) {
                    logger.log(Level.INFO, ex.getMessage());
                }
            } else if (id.name().equals(CompilerTokenId.USE)) {
                useOffset = ts.offset();
               
                ts.moveNext();
                skipWhitespaceComments(ts);
                //skip any number of periods
                boolean done = false;
                while (!done && ts.moveNext()) {
                    if (    !ts.token().id().name().equals(CompilerTokenId.PERIOD)
                        &&  !ts.token().id().name().equals(CompilerTokenId.ID)) {
                        //mark the location and check if there's another use statement
                        endUseOffset = ts.offset();
                        skipWhitespaceNewLinesComments(ts);
                        if (!ts.token().id().name().equals(CompilerTokenId.USE)) {
                            done = true;
                        } else {
                            ts.moveNext();
                            skipWhitespaceNewLinesComments(ts);
                        }
                    }
                }
               
                try {
                    operation.addToHierarchy(
                            USE_FOLD_TYPE,
                            USE_FOLD_TYPE.toString(),
                            false,
                            useOffset,
                            endUseOffset,
                            0,
                            0,
                            hierarchy,
                            transaction);
                } catch (BadLocationException ex) {
                    logger.log(Level.INFO, ex.getMessage());
                }
                ts.movePrevious();
                unskipWhitespaceNewLinesComments(ts);
               
            }//if it's an action, find its end position
            else if (id.name().equals(CompilerTokenId.ACTION)) {
                actionStart = id;
                actionStack = 0;
                ts.moveNext();
                Token<CompilerTokenId> search = null;
                int returnedOffset = skipWhitespaceComments(ts);
                actionOffset = ts.offset() + ts.token().length();
               
                ts.moveNext();
                returnedOffset = skipWhitespaceComments(ts);
               
                search = ts.token();
                if (search.id().name().equals(CompilerTokenId.LEFT_PAREN)) {
                    boolean done = false;
                    while (!done && ts.moveNext()) {
                        Token<CompilerTokenId> rightSide = ts.token();
                        if (rightSide.id().name().equals(CompilerTokenId.RIGHT_PAREN)) {
                            actionOffset = ts.offset() + ts.token().length();
                            ts.moveNext();
                            returnedOffset = skipWhitespaceComments(ts);
                            rightSide = ts.token();
                            if (rightSide.id().name().equals(CompilerTokenId.RETURNS)) {
                                ts.moveNext();
                                returnedOffset = skipWhitespaceComments(ts);
                                actionOffset = ts.offset() + ts.token().length();
                            } else if(rightSide.id().name().equals(CompilerTokenId.END)) {
                                ts.movePrevious();
                            }
                            done = true;
                        }
                        else if (rightSide.id().name().equals(CompilerTokenId.RETURNS)) {
                            done = true;
                            actionOffset = ts.offset() + ts.token().length();
                            ts.moveNext();
                            returnedOffset = skipWhitespaceComments(ts);
                            if(returnedOffset != -1) {
                                actionOffset = returnedOffset;
                            }
                            ts.moveNext();
                            actionOffset = ts.offset() + ts.token().length();
                        }
                    }
                } else if(search.id().name().equals(CompilerTokenId.RETURNS)) {
                    actionOffset = ts.offset() + ts.token().length();
                    ts.moveNext();
                    returnedOffset = skipWhitespaceComments(ts);
                    actionOffset = ts.offset() + ts.token().length();
                }
                else if(search.id().name().equals(CompilerTokenId.END)) {
                    ts.movePrevious();
                }
            } else if (id.name().equals(CompilerTokenId.IF)) {
                actionStack = actionStack + 1;
            } else if (id.name().equals(CompilerTokenId.REPEAT)) {
                actionStack = actionStack + 1;
            } else if (id.name().equals(CompilerTokenId.CHECK)) {
                actionStack = actionStack + 1;
            } else if (id.name().equals(CompilerTokenId.END)) {
                if (actionStack == 0 && actionOffset != -1) { //matching action statement
                    start = actionOffset;
                    try {
                        operation.addToHierarchy(
                                ACTION_FOLD_TYPE,
View Full Code Here

        if (info.input().readLength() < 1) {
            return null;
        } else if (token.getType() == -1) {
            return info.tokenFactory().createToken(QuorumLanguageHierarchy.getToken(10));
        }
        CompilerTokenId id = QuorumLanguageHierarchy.getToken(token.getType());
        org.netbeans.api.lexer.Token<CompilerTokenId> tId = info.tokenFactory().createToken(id);
        return tId;
    }
View Full Code Here

TOP

Related Classes of org.sodbeans.compiler.api.CompilerTokenId

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.