static { Precedence[] values = Precedence.values(); for (Precedence precedence : values) { int ordinal = precedence.ordinal(); precedence.higher = ordinal > 0 ? values[ordinal - 1] : null; } }
static { Set<IElementType> operations = new HashSet<IElementType>(); Precedence[] values = Precedence.values(); for (Precedence precedence : values) { operations.addAll(Arrays.asList(precedence.getOperations().getTypes())); } ALL_OPERATIONS = TokenSet.create(operations.toArray(new IElementType[operations.size()])); }
/* * element (operation element)* * * see the precedence table */ private void parseBinaryExpression(Precedence precedence) { // System.out.println(precedence.name() + " at " + myBuilder.getTokenText()); PsiBuilder.Marker expression = mark(); precedence.parseHigherPrecedence(this); while (!interruptedWithNewLine() && atSet(precedence.getOperations())) { IElementType operation = tt(); parseOperationReference(); KtNodeType resultType = precedence.parseRightHandSide(operation, this); expression.done(resultType); expression = expression.precede(); } expression.drop(); }