Examples of calcFirst()


Examples of org.intellij.grammar.analysis.BnfFirstNextAnalyzer.calcFirst()

  @Nullable
  public String generateDoc(final PsiElement element, final PsiElement originalElement) {
    if (element instanceof BnfRule) {
      final BnfRule rule = (BnfRule)element;
      BnfFirstNextAnalyzer analyzer = new BnfFirstNextAnalyzer();
      Set<String> first = analyzer.asStrings(analyzer.calcFirst(rule));
      Set<String> next = analyzer.asStrings(analyzer.calcNext(rule).keySet());

      StringBuilder docBuilder = new StringBuilder();
      String[] firstS = first.toArray(new String[first.size()]);
      Arrays.sort(firstS);
View Full Code Here

Examples of org.intellij.grammar.analysis.BnfFirstNextAnalyzer.calcFirst()

    for (BnfRule rule : myFile.getRules()) {
      if (Rule.isPrivate(rule) || Rule.isFake(rule)) continue;
      if (myRootRulesMap.containsKey(rule)) continue;
      Map<PsiElement, RuleGraphHelper.Cardinality> contentRules = myRuleGraph.getFor(rule);
      if (!contentRules.isEmpty()) continue;
      if (!analyzer.asStrings(analyzer.calcFirst(rule)).contains(rule.getName())) continue;

      ExpressionInfo expressionInfo = new ExpressionInfo(rule);
      addToPriorityMap(rule, myRuleGraph.getExtendsRules(rule), expressionInfo);
      List<BnfRule> rules = ParserGeneratorUtil.topoSort(expressionInfo.priorityMap.keySet(), myRuleGraph);
      for (BnfRule r : rules) {
View Full Code Here

Examples of org.intellij.grammar.analysis.BnfFirstNextAnalyzer.calcFirst()

  private void doTest(String text, boolean first, String... expected) {
    BnfFile f = (BnfFile)myFixture.configureByText("a.bnf", text);
    List<BnfRule> rules = f.getRules();
    assertFalse(rules.isEmpty());
    BnfFirstNextAnalyzer analyzer = new BnfFirstNextAnalyzer();
    Set<String> strings = analyzer.asStrings(first? analyzer.calcFirst(rules.get(0)) : analyzer.calcNext(rules.get(0)).keySet());
    String[] result = ArrayUtil.toStringArray(strings);
    Arrays.sort(result);
    assertOrderedEquals(result, expected);
  }
}
View Full Code Here

Examples of org.intellij.grammar.analysis.BnfFirstNextAnalyzer.calcFirst()

  private void doTest(String text, boolean first, String... expected) {
    BnfFile f = (BnfFile)myFixture.configureByText("a.bnf", text);
    List<BnfRule> rules = f.getRules();
    assertFalse(rules.isEmpty());
    BnfFirstNextAnalyzer analyzer = new BnfFirstNextAnalyzer();
    Set<String> strings = analyzer.asStrings(first? analyzer.calcFirst(rules.get(0)) : analyzer.calcNext(rules.get(0)).keySet());
    String[] result = ArrayUtil.toStringArray(strings);
    Arrays.sort(result);
    assertOrderedEquals(result, expected);
  }
}
View Full Code Here

Examples of org.intellij.grammar.analysis.BnfFirstNextAnalyzer.calcFirst()

  }

  public String generateFirstCheck(BnfRule rule, String frameName, boolean skipIfOne) {
    if (generateFirstCheck <= 0) return frameName;
    BnfFirstNextAnalyzer analyzer = new BnfFirstNextAnalyzer();
    Set<String> firstSet = analyzer.asStrings(analyzer.calcFirst(rule));
    List<String> firstElementTypes = new ArrayList<String>(firstSet.size());
    for (String s : firstSet) {
      if (myFile.getRule(s) != null) continue; // ignore left recursion
      @SuppressWarnings("StringEquality")
      boolean unknown = s == BnfFirstNextAnalyzer.MATCHES_EOF || s == BnfFirstNextAnalyzer.MATCHES_ANY;
View Full Code Here

Examples of org.intellij.grammar.analysis.BnfFirstNextAnalyzer.calcFirst()

      ArrayList<ProblemDescriptor> list = new ArrayList<ProblemDescriptor>();
      for (BnfRule rule : bnfFile.getRules()) {
        String ruleName = rule.getName();
        boolean exprParsing = ExpressionGeneratorHelper.getInfoForExpressionParsing(expressionHelper, rule) != null;

        if (!exprParsing && analyzer.asStrings(analyzer.calcFirst(rule)).contains(ruleName)) {
          list.add(manager.createProblemDescriptor(rule.getId(), "'" + ruleName + "' employs left-recursion unsupported by generator",
                                                   isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
        }
      }
      if (!list.isEmpty()) return list.toArray(new ProblemDescriptor[list.size()]);
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.