Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make an external rules as elementTypeClass? #289

Open
quovadis1234 opened this issue Oct 28, 2021 · 0 comments
Open

How to make an external rules as elementTypeClass? #289

quovadis1234 opened this issue Oct 28, 2021 · 0 comments

Comments

@quovadis1234
Copy link

quovadis1234 commented Oct 28, 2021

In my .bnf file, I define some rules as follow:

comb_identifier ::= IDENTIFIER | IDENTIFIER_PREDECLARED
OperandName ::= <<identifier_ref>> | QualifiedIdent {extends=Operand}

The code of external rule <<identifier_ref>> is

 public static boolean identifier_ref(PsiBuilder b, int level) {
        IElementType type = b.getTokenType();
        if (CueTokenTypes.IDENTIFIERS.contains(type)) {
            b.advanceLexer();
            return true;
        }

        // null is a NULL_LIT, true and false are BOOL_LIT, all others are KEYWORD, so we can just remap KEYWORD
        if (type == CueTypes.KEYWORD) {
            b.remapCurrentToken(CueTypes.IDENTIFIER);
            b.advanceLexer();
            return true;
        }
        return false;
    }

It is used for transforming KEYWORD to IDENTIFIER in an OperandName.
I want to replace the <<identifier_ref>> by comb_identifier, so I can resolve the reference of comb_identifier in an OperandName. But if I do so, KEYWORD cannot be remapped as IDENTIFIER. What can I do to achieve my purpose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant