void () { // By standard here could be no more than one TAG or ANCHOR // By better to support sequence of them boolean anchorWasRead = false; boolean tagWasRead = false; while (getTokenType() == YAMLTokenTypes.TAG || getTokenType() == YAMLTokenTypes.AMPERSAND) { if (getTokenType() == YAMLTokenTypes.AMPERSAND) { PsiBuilder.Marker errorMarker = null; if (anchorWasRead) { errorMarker = mark(); } anchorWasRead = true; PsiBuilder.Marker anchorMarker = mark(); advanceLexer(); // symbol & if (getTokenType() == YAMLTokenTypes.ANCHOR) { advanceLexer(); // anchor name anchorMarker.done(YAMLElementTypes.ANCHOR_NODE); } else { // Should be impossible now (because of lexer rules) anchorMarker.drop(); } if (errorMarker != null) { errorMarker.error(YAMLBundle.message("YAMLParser.multiple.anchors")); } } else { // tag case if (tagWasRead) { PsiBuilder.Marker errorMarker = mark(); advanceLexer(); errorMarker.error(YAMLBundle.message("YAMLParser.multiple.tags")); } else { tagWasRead = true; advanceLexer(); } } } }