Skip to content

Commit

Permalink
reduce keyword capture
Browse files Browse the repository at this point in the history
  • Loading branch information
wrapperup committed Mar 7, 2024
1 parent c93291c commit 74f21ab
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions corpus/main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Expressions
(code))
(content)
(tag
(keyword)
(code))
(content)
(tag
Expand Down
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = grammar({
// General rule for keyword tags
// It just tries to match the first word in a tag block,
// plus any other special characters that might be present
keyword: $ => /[a-zA-Z0-9\(\)\.>]+/,
keyword: $ => /[a-zA-Z>]+/,
close_keyword: $ => /\/[a-zA-Z]+/,

filter: $ => repeat1(seq(
Expand Down
2 changes: 1 addition & 1 deletion src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
},
"keyword": {
"type": "PATTERN",
"value": "[a-zA-Z0-9\\(\\)\\.>]+"
"value": "[a-zA-Z>]+"
},
"close_keyword": {
"type": "PATTERN",
Expand Down
11 changes: 2 additions & 9 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
lookahead == '\n' ||
lookahead == '\r' ||
lookahead == ' ') SKIP(0)
if (lookahead == '(' ||
lookahead == ')' ||
('.' <= lookahead && lookahead <= '9') ||
lookahead == '>' ||
if (lookahead == '>' ||
('A' <= lookahead && lookahead <= 'Z') ||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(17);
END_STATE();
Expand Down Expand Up @@ -283,11 +280,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
END_STATE();
case 17:
ACCEPT_TOKEN(sym_keyword);
if (lookahead == '(' ||
lookahead == ')' ||
lookahead == '.' ||
('0' <= lookahead && lookahead <= '9') ||
lookahead == '>' ||
if (lookahead == '>' ||
('A' <= lookahead && lookahead <= 'Z') ||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(17);
END_STATE();
Expand Down

0 comments on commit 74f21ab

Please sign in to comment.