diff --git a/corpus/env.txt b/corpus/env.txt index 245599b..6079e83 100644 --- a/corpus/env.txt +++ b/corpus/env.txt @@ -26,6 +26,20 @@ ENV TEST_2=value\ 2 name: (unquoted_string) value: (unquoted_string)))) +========================================================= +Single-letter variable +========================================================= + +ENV X=42 + +--- + +(source_file + (env_instruction + (env_pair + (unquoted_string) + (unquoted_string)))) + ================================================================================ Multiple ================================================================================ diff --git a/grammar.js b/grammar.js index f1a1a88..8acf84d 100644 --- a/grammar.js +++ b/grammar.js @@ -195,7 +195,7 @@ module.exports = grammar({ ), _env_key: ($) => - alias(/[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]/, $.unquoted_string), + alias(/[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])?/, $.unquoted_string), expose_port: ($) => seq(/\d+/, optional(choice("/tcp", "/udp"))), diff --git a/src/grammar.json b/src/grammar.json index 948b931..c4d0d41 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -941,7 +941,7 @@ "type": "ALIAS", "content": { "type": "PATTERN", - "value": "[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]" + "value": "[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])?" }, "named": true, "value": "unquoted_string" diff --git a/src/parser.c b/src/parser.c index 375ea04..734052d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1078,7 +1078,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead == '\r' || lookahead == ' ') SKIP(5) if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(52); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(204); END_STATE(); case 6: if (lookahead == '\n') ADVANCE(160); @@ -1283,7 +1283,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead == '\r' || lookahead == ' ') SKIP(22) if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(52); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(204); END_STATE(); case 23: if (lookahead == '\n') ADVANCE(160); @@ -1488,7 +1488,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead == '\r' || lookahead == ' ') SKIP(45) if (('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(52); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(204); END_STATE(); case 46: if (lookahead == '\\') ADVANCE(1);