Examples of ATEToken


Examples of org.antlr.works.ate.syntax.misc.ATEToken

        return getEndIndex()-getStartIndex();
    }

    public int getInternalTokensStartIndex() {
        for(Iterator<ATEToken> iter = getTokens().iterator(); iter.hasNext(); ) {
            ATEToken token = iter.next();
            if(token.getAttribute().equals(":")) {
                token = iter.next();
                return token.getStartIndex();
            }
        }
        return -1;
    }
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

        }
        return -1;
    }

    public int getInternalTokensEndIndex() {
        ATEToken token = parser.getTokens().get(end.index-1);
        return token.getEndIndex();
    }
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

    public boolean detectLeftRecursion() {
        for (List<ATEToken> alts : getAlternatives()) {
            if (alts.isEmpty())
                continue;

            ATEToken firstTokenInAlt = alts.get(0);
            if (firstTokenInAlt.getAttribute().equals(name))
                return true;
        }
        return false;
    }
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

    public String getTextRuleAfterRemovingLeftRecursion() {
        StringBuilder head = new StringBuilder();
        StringBuilder star = new StringBuilder();

        for (List<ATEToken> alts : getAlternatives()) {
            ATEToken firstTokenInAlt = alts.get(0);
            if (firstTokenInAlt.getAttribute().equals(name)) {
                if (alts.size() > 1) {
                    if (star.length() > 0)
                        star.append(" | ");
                    int start = (alts.get(1)).getStartIndex();
                    int end = (alts.get(alts.size() - 1)).getEndIndex();
                    star.append(firstTokenInAlt.getText().substring(start, end));
                }
            } else {
                if (head.length() > 0)
                    head.append(" | ");
                int start = firstTokenInAlt.getStartIndex();
                int end = (alts.get(alts.size() - 1)).getEndIndex();
                head.append(firstTokenInAlt.getText().substring(start, end));
            }
        }

        StringBuilder sb = new StringBuilder();
        sb.append("(");
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

        }
        return names;
    }

    public int getFirstDeclarationPosition(String name) {
        ATEToken token = getFirstDeclaration(name);
        if(token != null) {
            return token.start;
        } else {
            return -1;
        }
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

                doc.insertString(offset, "\t"+c2, null);
            }
        } else if(c2 == ':') {
            // Disable the auto-indent on ':' if we are in a block, action, etc.
            // This is indicated by the fact that the token has a scope.
            ATEToken token = window.getCurrentToken();
            if(token != null && token.scope != null)
                return;

            // Try to reach the beginning of the line by parsing only an ID
            // (which is the rule name)
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

    /**
     * Parses for the tokenVocab key/value pair of a block of type 'options'
     */
    private void parseForTokenVocab() {
        for(int index=0; index<internalTokens.size(); index++) {
            ATEToken t = internalTokens.get(index);
            if(t.getAttribute().equals("tokenVocab") && index+2<internalTokens.size()) {
                t = internalTokens.get(index+2);
                tokenVocab = t.getAttribute();
            }
        }
    }
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

     * ...
     */
    private void parseForTokens() {
        declaredTokens = new ArrayList<ATEToken>();
        for(int index=0; index<internalTokens.size(); index++) {
            ATEToken t = internalTokens.get(index);
            if(t.getAttribute().equals("=")) {
                declaredTokens.add(internalTokens.get(index-1));
                // skip the value and the semi
                index += 2;
            } else if(t.getAttribute().equals(";")) {
                declaredTokens.add(internalTokens.get(index-1));
                // skip the semi
                index++;

            }
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

     *
     * @param externalNames A list of string representing the external declared reference names
     */
    public void resolveReferencesWithExternalNames(Set<String> externalNames) {
        for(int i=unresolvedReferences.size()-1; i >= 0; i--) {
            ATEToken ref = unresolvedReferences.get(i);
            if(externalNames.contains(ref.getAttribute())) {
                ref.type = GrammarSyntaxLexer.TOKEN_REFERENCE;
                references.add(new ElementReference(refsToRules.get(ref), ref));
                unresolvedReferences.remove(i);
            }
        }
View Full Code Here

Examples of org.antlr.works.ate.syntax.misc.ATEToken

    /**
     * Resolves the unresolved references by looking at the set of declared references
     */
    private void resolveReferences() {
        for(int i=unresolvedReferences.size()-1; i >= 0; i--) {
            ATEToken ref = unresolvedReferences.get(i);
            if(declaredReferenceNames.contains(ref.getAttribute())) {
                ref.type = GrammarSyntaxLexer.TOKEN_REFERENCE;
                references.add(new ElementReference(refsToRules.get(ref), ref));
                unresolvedReferences.remove(i);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.