aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-10-28 02:15:21 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-10-28 02:15:21 +0200
commit2483cbddd9e7a02296bb928462ba7eb22551752d (patch)
tree53ca344996b9ed8db7e3b3fa609398692880a332
parent497edc25a278edf743eef0b4ac1e31d079d3f4bf (diff)
Allow ID- and class shorthands to have anythingv1.0.1
-rw-r--r--grammar.js4
-rw-r--r--src/grammar.json4
-rw-r--r--src/parser.c40
3 files changed, 24 insertions, 24 deletions
diff --git a/grammar.js b/grammar.js
index 1e65ebc..5849132 100644
--- a/grammar.js
+++ b/grammar.js
@@ -43,8 +43,8 @@ module.exports = grammar({
),
),
- class_shorthand: $ => /\.[a-zA-Z0-9_-]+/,
- id_shorthand: $ => /#[a-zA-Z0-9_-]+/,
+ class_shorthand: $ => /\.[^\s]+/,
+ id_shorthand: $ => /#[^\s]+/,
attribute_name: $ => /[a-zA-Z0-9_-]+/,
attribute_value: $ => /"(\\.|[^"\\])*"/,
diff --git a/src/grammar.json b/src/grammar.json
index bc4e69c..150b1a5 100644
--- a/src/grammar.json
+++ b/src/grammar.json
@@ -180,11 +180,11 @@
},
"class_shorthand": {
"type": "PATTERN",
- "value": "\\.[a-zA-Z0-9_-]+"
+ "value": "\\.[^\\s]+"
},
"id_shorthand": {
"type": "PATTERN",
- "value": "#[a-zA-Z0-9_-]+"
+ "value": "#[^\\s]+"
},
"attribute_name": {
"type": "PATTERN",
diff --git a/src/parser.c b/src/parser.c
index 983827a..97761e6 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -336,18 +336,18 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
if (lookahead != 0) ADVANCE(16);
END_STATE();
case 4:
- if (lookahead == '-' ||
- ('0' <= lookahead && lookahead <= '9') ||
- ('A' <= lookahead && lookahead <= 'Z') ||
- lookahead == '_' ||
- ('a' <= lookahead && lookahead <= 'z')) ADVANCE(19);
+ if (lookahead != 0 &&
+ lookahead != '\t' &&
+ lookahead != '\n' &&
+ lookahead != '\r' &&
+ lookahead != ' ') ADVANCE(19);
END_STATE();
case 5:
- if (lookahead == '-' ||
- ('0' <= lookahead && lookahead <= '9') ||
- ('A' <= lookahead && lookahead <= 'Z') ||
- lookahead == '_' ||
- ('a' <= lookahead && lookahead <= 'z')) ADVANCE(18);
+ if (lookahead != 0 &&
+ lookahead != '\t' &&
+ lookahead != '\n' &&
+ lookahead != '\r' &&
+ lookahead != ' ') ADVANCE(18);
END_STATE();
case 6:
if (lookahead != 0 &&
@@ -403,19 +403,19 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
END_STATE();
case 18:
ACCEPT_TOKEN(sym_class_shorthand);
- if (lookahead == '-' ||
- ('0' <= lookahead && lookahead <= '9') ||
- ('A' <= lookahead && lookahead <= 'Z') ||
- lookahead == '_' ||
- ('a' <= lookahead && lookahead <= 'z')) ADVANCE(18);
+ if (lookahead != 0 &&
+ lookahead != '\t' &&
+ lookahead != '\n' &&
+ lookahead != '\r' &&
+ lookahead != ' ') ADVANCE(18);
END_STATE();
case 19:
ACCEPT_TOKEN(sym_id_shorthand);
- if (lookahead == '-' ||
- ('0' <= lookahead && lookahead <= '9') ||
- ('A' <= lookahead && lookahead <= 'Z') ||
- lookahead == '_' ||
- ('a' <= lookahead && lookahead <= 'z')) ADVANCE(19);
+ if (lookahead != 0 &&
+ lookahead != '\t' &&
+ lookahead != '\n' &&
+ lookahead != '\r' &&
+ lookahead != ' ') ADVANCE(19);
END_STATE();
case 20:
ACCEPT_TOKEN(sym_attribute_name);