Package org.antlr.works.grammar.element

Examples of org.antlr.works.grammar.element.ElementRule


        // 'rules' is a list of set of rules given by ANTLR
        for (Object ruleSet : rules) {
            final Set rulesSet = (Set) ruleSet;
            for (Object rule : rulesSet) {
                final Rule aRule = (Rule) rule;
                final ElementRule r = engine.getRuleWithName(aRule.name);
                if (r == null)
                    continue;
                r.setLeftRecursiveRulesSet(rulesSet);
            }
        }
    }
View Full Code Here


    protected boolean willLaunch() {

        if(!checkForCurrentRule())
            return false;

        ElementRule rule = window.getCurrentRule();
        List<ElementReference> refs = window.editorRules.getReferencesInRule(rule);
        if(refs == null || refs.isEmpty()) {
            XJAlert.display(window.getJavaContainer(), "Error", "The selected rule doesn't contain any references");
            return false;
        }
View Full Code Here

        return true;
    }

    @Override
    public String getDOTString() throws Exception {
        ElementRule rule = window.getCurrentRule();

        visitedRules.clear();
        visitedRefs.clear();

        dependency = new StringBuilder();
View Full Code Here

        Usages usage = new Usages(delegate, token);
        delegate.addUsagesTab(usage);

        for (ATEToken ateToken : delegate.getTokens()) {
            if (ateToken.getAttribute().equals(token.getAttribute())) {
                ElementRule matchedRule = delegate.getEditorRules().getEnclosingRuleAtPosition(ateToken.getStartIndex());
                if (matchedRule != null)
                    usage.addMatch(matchedRule, ateToken);
            }
        }
    }
View Full Code Here

        this.window = window;
    }

    public void showTokensSD() {
        StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_SHOW_TOKENS_SD);
        window.syntaxDiagramTab.setRule(new ElementRule(Grammar.ARTIFICIAL_TOKENS_RULENAME), true);
    }
View Full Code Here

        if(s != null && s.length() > 0) {
            List<ElementRule> rules = window.editorRules.getSelectedRules();
            if(!rules.isEmpty()) {
                window.beginGroupChange("Group");

                ElementRule firstRule = rules.get(0);
                ElementRule lastRule = rules.get(rules.size()-1);

                int end = lastRule.getEndIndex();
                window.getTextEditor().insertText(end+1, "\n"+ GrammarSyntaxParser.END_GROUP+"\n");

                int start = firstRule.getStartIndex();
                window.getTextEditor().insertText(start-1, "\n"+ GrammarSyntaxParser.BEGIN_GROUP+s+"\n");
View Full Code Here

    protected boolean willLaunch() {
        return true;
    }

    protected boolean checkForCurrentRule() {
        ElementRule rule = window.getCurrentRule();
        if(rule == null) {
            XJAlert.display(window.getJavaContainer(), "Error", "The cursor must be inside a rule");
            return false;
        }
        return true;
View Full Code Here

    public void setCaretPosition(int position) {
        setCaretPosition(position, AWPrefs.getSmoothScrolling());
    }

    private void setCaretPosition(int position, boolean animate) {
        ElementRule rule = editorRules.getEnclosingRuleAtPosition(position);
        if(rule != null && !rule.isExpanded()) {
            foldingManager.toggleFolding(rule);
        }
        textEditor.setCaretPosition(position, true, animate);
    }
View Full Code Here

        return textEditor.getCaretPosition();
    }

    public void updateVisualization(boolean immediate) {
        if(syntaxDiagramTab.isEnabled()) {
            ElementRule r = editorRules.getEnclosingRuleAtPosition(getCaretPosition());
            if(r == null) {
                syntaxDiagramTab.setPlaceholder("Select a rule to display its syntax diagram");
            } else {
                if(r.hasErrors() && r.needsToBuildErrors()) {
                    grammarEngine.computeRuleErrors(r);
                    try {
                        syntaxDiagramTab.createGraphsForRule(r);
                    } catch (Exception e) {
                        // ignore
View Full Code Here

    public GoToRule getGoToRule() {
        return goToRule;
    }

    public boolean goToRule(String ruleName) {
        ElementRule rule = editorRules.selectRuleNameInTree(ruleName);
        if(rule != null) {
            goToHistoryRememberCurrentPosition();
            editorRules.goToRule(rule);
            return true;
        }
View Full Code Here

TOP

Related Classes of org.antlr.works.grammar.element.ElementRule

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.