Skip to content

Commit

Permalink
fix(dtd): don't include XML symbols in scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Oct 21, 2024
1 parent aea2507 commit 24bd154
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ enum TokenType {
PI_TARGET,
PI_CONTENT,
COMMENT,

#ifdef TS_XML
CHAR_DATA,
CDATA,
XML_MODEL,
Expand All @@ -15,6 +17,7 @@ enum TokenType {
END_TAG_NAME,
ERRONEOUS_END_NAME,
SELF_CLOSING_TAG_DELIMITER,
#endif
};

/// Advance the lexer if the next token matches the given character
Expand Down Expand Up @@ -52,6 +55,9 @@ static inline bool check_word(TSLexer *lexer, const char *const word, unsigned l
/// Scan for the target of a PI node
static bool scan_pi_target(TSLexer *lexer, const bool *valid_symbols) {
bool advanced_once = false, found_x_first = false;
#ifndef TS_XML
(void)valid_symbols;
#endif

if (is_valid_name_start_char(lexer->lookahead)) {
if (lexer->lookahead == 'x' || lexer->lookahead == 'X') {
Expand All @@ -69,6 +75,7 @@ static bool scan_pi_target(TSLexer *lexer, const bool *valid_symbols) {
if (lexer->lookahead == 'l' || lexer->lookahead == 'L') {
advance(lexer);
if (is_valid_name_char(lexer->lookahead)) {
#ifdef TS_XML
found_x_first = false;
bool last_char_hyphen = lexer->lookahead == '-';
advance(lexer);
Expand All @@ -78,6 +85,7 @@ static bool scan_pi_target(TSLexer *lexer, const bool *valid_symbols) {
if (valid_symbols[XML_STYLESHEET] && check_word(lexer, "stylesheet", 10))
return false;
}
#endif
} else {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions xml/src/scanner.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define TS_XML
#include "../../common/scanner.h"
#include "tree_sitter/array.h"

Expand Down

0 comments on commit 24bd154

Please sign in to comment.