Skip to content

Commit

Permalink
Fixing parser slowdown for "nested" generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Jan 27, 2024
1 parent ca70eb3 commit bc2f04a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/intellij/plugins/haxe/lang/parser/haxe.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,10 @@ mapLiteral ::= '[' (mapInitializerStatement | mapInitializerExpressionList) ']'
optionalMark ::= '?'
functionType ::= newFunctionType | oldFunctionType
functionReturnType ::= typeWrapper

private typeWrapper ::= functionType | typeOrAnonymous
// normal types have type parameters that can be nested so its best to check types before function types/function signatures
// as functions are not nested and checking them first will cause a wasted function type check on every nested type in normal types
// to avoid normal types from consume tokens from function type we add should not end with function type check ( !'->')
private typeWrapper ::= typeOrAnonymous !'->' | functionType

private newFunctionType ::= '(' functionArgumentsList ')' '->' functionReturnType {pin=3}
private functionArgumentsList ::= [!')' functionArgument (',' functionArgument)*]
Expand Down

0 comments on commit bc2f04a

Please sign in to comment.