Examples of BnfExpression


Examples of org.intellij.grammar.psi.BnfExpression

    final String name = location.method().name();
    int lineNumber = location.lineNumber() - 1;

    for (PsiFile file : myGrammars.get(qname)) {
      BnfExpression expression = findExpression(file, name);
      BnfRule rule = PsiTreeUtil.getParentOfType(expression, BnfRule.class);
      if (expression != null && qname.equals(ParserGeneratorUtil.getAttribute(rule, KnownAttribute.PARSER_CLASS))) {
        for (BnfExpression expr : ParserGeneratorUtil.getChildExpressions(expression)) {
          int line = getLineNumber(expr, qname, lineNumber);
          if (line == lineNumber) {
View Full Code Here

Examples of org.intellij.grammar.psi.BnfExpression

    String methodName = GrammarUtil.getMethodName(rule, element);
    PsiMethod[] methods = aClass.findMethodsByName(methodName, false);
    PsiCodeBlock body = methods.length == 1? methods[0].getBody() : null;
    PsiStatement[] statements = body != null ? body.getStatements() : PsiStatement.EMPTY_ARRAY;

    BnfExpression expr = PsiTreeUtil.getParentOfType(element, BnfExpression.class, false);
    PsiElement parent = expr != null? expr.getParent() : null;
    if (parent instanceof BnfExpression) {
      int index = ParserGeneratorUtil.getChildExpressions((BnfExpression)parent).indexOf(expr);
      for (int i = 0, len = statements.length, j = 0; i < len; i++) {
        PsiStatement cur = statements[i];
        String text = cur.getText();
View Full Code Here

Examples of org.intellij.grammar.psi.BnfExpression

        BnfAttr attr = bnfFile.findAttribute(pinMatcher.rule, KnownAttribute.PIN, pinMatcher.funcName);
        return pinned.add(Pair.create(bnfExpression, attr));
      }
    });
    for (int i = 0, len = pinned.size(); i < len; i++) {
      BnfExpression e = pinned.get(i).first;
      BnfExpression prev = i == 0? null : pinned.get(i - 1).first;
      BnfAttr attr = pinned.get(i).second;
      boolean fullRange = prev == null || !PsiTreeUtil.isAncestor(e, prev, true);
      TextRange textRange = e.getTextRange();
      TextRange infoRange = fullRange ? textRange : TextRange.create(prev.getTextRange().getEndOffset() + 1, textRange.getEndOffset());
      String message = attr == null? (fullRange ? "pinned" : "pinned again") : attr.getText();
      annotationHolder.createInfoAnnotation(infoRange, message).setTextAttributes(BnfSyntaxHighlighter.PIN_MARKER);
    }
  }
View Full Code Here

Examples of org.intellij.grammar.psi.BnfExpression

    Set<BnfExpression> visited = new THashSet<BnfExpression>();
    THashSet<BnfExpression> first = new THashSet<BnfExpression>();
    BnfFirstNextAnalyzer analyzer = new BnfFirstNextAnalyzer();
    List<BnfExpression> list = choice.getExpressionList();
    for (int i = 0, listSize = list.size() - 1; i < listSize; i++) {
      BnfExpression child = list.get(i);
      Set<String> firstSet = analyzer.asStrings(analyzer.calcFirstInner(child, first, visited));
      if (firstSet.contains(BnfFirstNextAnalyzer.MATCHES_NOTHING)) {
        registerProblem(choice, child, "Branch is unable to match anything due to & or ! conditions", problemsHolder);
      }
      else if (firstSet.contains(BnfFirstNextAnalyzer.MATCHES_EOF)) {
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.