1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add a keyword for abstract classes in GDScript

Co-authored-by: Danil Alexeev <danil@alexeev.xyz>
This commit is contained in:
Aaron Franke
2023-10-08 16:22:25 -05:00
parent 730adf4801
commit 067704f1cd
17 changed files with 137 additions and 42 deletions

View File

@@ -101,6 +101,7 @@ static const char *token_names[] = {
"match", // MATCH,
"when", // WHEN,
// Keywords
"abstract", // ABSTRACT,
"as", // AS,
"assert", // ASSERT,
"await", // AWAIT,
@@ -198,6 +199,7 @@ bool GDScriptTokenizer::Token::is_identifier() const {
case IDENTIFIER:
case MATCH: // Used in String.match().
case WHEN: // New keyword, avoid breaking existing code.
case ABSTRACT:
// Allow constants to be treated as regular identifiers.
case CONST_PI:
case CONST_INF:
@@ -213,6 +215,7 @@ bool GDScriptTokenizer::Token::is_node_name() const {
// This is meant to allow keywords with the $ notation, but not as general identifiers.
switch (type) {
case IDENTIFIER:
case ABSTRACT:
case AND:
case AS:
case ASSERT:
@@ -495,6 +498,7 @@ GDScriptTokenizer::Token GDScriptTokenizerText::annotation() {
#define KEYWORDS(KEYWORD_GROUP, KEYWORD) \
KEYWORD_GROUP('a') \
KEYWORD("abstract", Token::ABSTRACT) \
KEYWORD("as", Token::AS) \
KEYWORD("and", Token::AND) \
KEYWORD("assert", Token::ASSERT) \