rust-analyzer / rowan

Apache License 2.0
689 stars 57 forks source link

Separate types for token kinds and node kinds #83

Open lunacookies opened 3 years ago

lunacookies commented 3 years ago

Although using a single type for both (SyntaxKind) is easier, it doesn’t make illegal states unrepresentable. For example, if I’m matching on a SyntaxKind produced by my lexer, I know that the kind cannot be one of SyntaxKind’s node variants, e.g. BinaryExpr. Similarly, when I’m deciding what kind to give a node, I shouldn’t be able to create a node of kind LetKw.