Package com.creativewidgetworks.goldparser.engine

Examples of com.creativewidgetworks.goldparser.engine.Token


     * grammars where indentation is important (e.g. Python, etc.)
     * @return Token
     */
    @Override
    protected Token nextToken() {
        Token token;

        // Indent virtual terminals
        if (useIndentVirtualTerminals) {
            if (ivtTokens.isEmpty()) {
                // Get next token from stream
                token = produceToken();
               
                // Token's position in source - initialize indentLevel stack
                Position position = token.getPosition();
                if (ivtIndentLevels.isEmpty()) {
                    ivtLine = position.getLine();
                    ivtIndentLevels.push(position);
                }
               
                // Trigger on change of line number
                if (position.getLine() != ivtLine) {
                    ivtLine = position.getLine();
                    int ivtColumn = ivtIndentLevels.peek().getColumn();
                    if (position.getColumn() > ivtColumn) {
                        ivtTokens.push(token);
                        ivtIndentLevels.push(position);
                        token = new Token(getSymbolByName(VT_INDENT_INCREASE), getIndentLevels(), position);
                    } else if (token.getPosition().getColumn() < ivtColumn) {
                        ivtTokens.push(token);
                        while (!ivtIndentLevels.isEmpty() && ivtIndentLevels.peek().getColumn() > position.getColumn()) {
                            ivtIndentLevels.pop();
                            ivtTokens.push(new Token(getSymbolByName(VT_INDENT_DECREASE), getIndentLevels(), position));
                        }
                        token = ivtTokens.pop();
                    }
                }
               
View Full Code Here

TOP

Related Classes of com.creativewidgetworks.goldparser.engine.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.