Package com.intellij.lang.PsiBuilder

Examples of com.intellij.lang.PsiBuilder.Marker


public class LatteParser implements PsiParser {
    @NotNull
    @Override
    public ASTNode parse(IElementType root, PsiBuilder builder) {
        Marker marker = builder.mark();
       
        // Process all tokens
        while(!builder.eof()) {
            IElementType type = builder.getTokenType();

            if(type == LatteTokenTypes.OPENING) parseMacro(builder);
            else if(type == LatteTokenTypes.N_ATTR) parseNAttr(builder);

            builder.advanceLexer(); // move to next token
        }
       
        marker.done(root);
        return builder.getTreeBuilt();
    }
View Full Code Here


        return builder.getTreeBuilt();
    }

    // {macro ...}
    private void parseMacro(PsiBuilder builder) {
        Marker macroStart = builder.mark();
        builder.advanceLexer();

        // is there a name?
        String tagName = null;
        if(builder.getTokenType() == LatteTokenTypes.MACRO_NAME) {
            Marker macroNameMark = builder.mark();
            tagName = builder.getTokenText();
            builder.advanceLexer();
            macroNameMark.done(LatteTokenTypes.MACRO_NAME);
        }

        // params
        Marker paramsMark = builder.mark();
        parseParams(tagName, builder, LatteTokenTypes.CLOSING);
        paramsMark.done(LatteTokenTypes.PARAMS);

        // finish him
        if(builder.getTokenType() == LatteTokenTypes.CLOSING) {
            builder.advanceLexer();
        }
View Full Code Here

    }

    // n:link="something"
    // n:link=something
    private void parseNAttr(PsiBuilder builder) {
        Marker start = builder.mark();
        builder.advanceLexer();
       
        // Process name
        String attrName = null;
        if(builder.getTokenType() == LatteTokenTypes.ATTR_NAME) {
            Marker macroName =  builder.mark();
            attrName = "@" + builder.getTokenText();
            builder.advanceLexer();
            macroName.done(LatteTokenTypes.MACRO_NAME);
        }
       
        if(builder.getTokenType() == LatteTokenTypes.N_ATTR_EQ) builder.advanceLexer();
       
        boolean inQuotes;
        if(builder.getTokenType() == LatteTokenTypes.N_QUOTE) {
            inQuotes = true;
            builder.advanceLexer();
        } else inQuotes = false;


        // Process value
        Marker value = builder.mark();
        parseParams(attrName, builder, inQuotes ? LatteTokenTypes.N_QUOTE : LatteTokenTypes.TEMPLATE_HTML_TEXT);
        value.done(LatteTokenTypes.PARAMS);

        if(inQuotes && builder.getTokenType() == LatteTokenTypes.N_QUOTE) {
            builder.advanceLexer();
        }
View Full Code Here

  public static boolean typedefDeclaration(PsiBuilder builder_, int level_) {
    if (!recursion_guard_(builder_, level_, "typedefDeclaration")) return false;
    if (!nextTokenIs(builder_, "<typedef declaration>", KEXTERN, KPRIVATE, KTYPEDEF)) return false;
    boolean result_;
    boolean pinned_;
    Marker marker_ = enter_section_(builder_, level_, _NONE_, "<typedef declaration>");
    result_ = typedefDeclaration_0(builder_, level_ + 1);
    result_ = result_ && consumeToken(builder_, KTYPEDEF);
    pinned_ = result_; // pin = 2
    result_ = result_ && report_error_(builder_, componentName(builder_, level_ + 1));
    result_ = pinned_ && report_error_(builder_, typedefDeclaration_3(builder_, level_ + 1)) && result_;
View Full Code Here

  // '>' '>' '>'
  public static boolean unsignedShiftRightOperator(PsiBuilder builder_, int level_) {
    if (!recursion_guard_(builder_, level_, "unsignedShiftRightOperator")) return false;
    if (!nextTokenIs(builder_, OGREATER)) return false;
    boolean result_;
    Marker marker_ = enter_section_(builder_);
    result_ = consumeToken(builder_, OGREATER);
    result_ = result_ && consumeToken(builder_, OGREATER);
    result_ = result_ && consumeToken(builder_, OGREATER);
    exit_section_(builder_, marker_, UNSIGNED_SHIFT_RIGHT_OPERATOR, result_);
    return result_;
View Full Code Here

  public static boolean usingStatement(PsiBuilder builder_, int level_) {
    if (!recursion_guard_(builder_, level_, "usingStatement")) return false;
    if (!nextTokenIs(builder_, KUSING)) return false;
    boolean result_;
    boolean pinned_;
    Marker marker_ = enter_section_(builder_, level_, _NONE_, null);
    result_ = consumeToken(builder_, KUSING);
    pinned_ = result_; // pin = 1
    result_ = result_ && report_error_(builder_, simpleQualifiedReferenceExpression(builder_, level_ + 1));
    result_ = pinned_ && consumeToken(builder_, OSEMI) && result_;
    exit_section_(builder_, level_, marker_, USING_STATEMENT, result_, pinned_, null);
View Full Code Here

    if (!nextTokenIs(builder_, "", PLPAREN, PLBRACK,
      KCAST, KFALSE, KFUNCTION, KIF, ONEW, KNULL,
      KSUPER, KSWITCH, KTHIS, KTRUE, KTRY, KUNTYPED,
      PLCURLY, ID, LITFLOAT, LITHEX, LITINT, LITOCT, OPEN_QUOTE, REG_EXP)) return false;
    boolean result_;
    Marker marker_ = enter_section_(builder_);
    result_ = value_0(builder_, level_ + 1);
    if (!result_) result_ = value_1(builder_, level_ + 1);
    if (!result_) result_ = ifStatement(builder_, level_ + 1);
    if (!result_) result_ = value_3(builder_, level_ + 1);
    if (!result_) result_ = newExpressionOrCall(builder_, level_ + 1);
View Full Code Here

  // 'untyped' expression
  private static boolean value_0(PsiBuilder builder_, int level_) {
    if (!recursion_guard_(builder_, level_, "value_0")) return false;
    boolean result_;
    Marker marker_ = enter_section_(builder_);
    result_ = consumeToken(builder_, KUNTYPED);
    result_ = result_ && expression(builder_, level_ + 1);
    exit_section_(builder_, marker_, null, result_);
    return result_;
  }
View Full Code Here

  // literalExpression qualifiedReferenceTail?
  private static boolean value_1(PsiBuilder builder_, int level_) {
    if (!recursion_guard_(builder_, level_, "value_1")) return false;
    boolean result_;
    Marker marker_ = enter_section_(builder_);
    result_ = literalExpression(builder_, level_ + 1);
    result_ = result_ && value_1_1(builder_, level_ + 1);
    exit_section_(builder_, marker_, null, result_);
    return result_;
  }
View Full Code Here

  // castExpression qualifiedReferenceTail?
  private static boolean value_3(PsiBuilder builder_, int level_) {
    if (!recursion_guard_(builder_, level_, "value_3")) return false;
    boolean result_;
    Marker marker_ = enter_section_(builder_);
    result_ = castExpression(builder_, level_ + 1);
    result_ = result_ && value_3_1(builder_, level_ + 1);
    exit_section_(builder_, marker_, null, result_);
    return result_;
  }
View Full Code Here

TOP

Related Classes of com.intellij.lang.PsiBuilder.Marker

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.