void () { doTest("a2b", """ Element(ROOT) Element(LETTER) PsiElement(LETTER)('a') PsiErrorElement:no digits allowed PsiElement(DIGIT)('2') Element(LETTER) PsiElement(LETTER)('b') """, builder -> { IElementType tokenType; while ((tokenType = builder.getTokenType()) != null) { PsiBuilder.Marker marker = builder.mark(); builder.advanceLexer(); if (tokenType == DIGIT) marker.error("no digits allowed"); else marker.done(tokenType); } } ); }