ts-parser-perl 1.2.0

Actively maintained tree-sitter grammar for Perl
Documentation
/* THIS FILE IS GENERATED BY generate_keywords.pl
 *
 * Statement keywords recognized by peek_is_statement_keyword().
 * To add a keyword, edit the @keywords list in generate_keywords.pl
 * and re-run: perl generate_keywords.pl
 *
 * Current keywords: class, method, no, package, role, sub, use
 */

// First-char filter: returns PEEK_NO_MATCH immediately if the
// lookahead can't start any statement keyword.
#define KEYWORD_FIRST_CHAR_FILTER(la) \
  (!(la == 'c' || la == 'm' || la == 'n' || la == 'p' || la == 'r' || la == 's' || la == 'u'))

// Word-reading loop: characters that appear in any keyword.
#define KEYWORD_WORD_CHAR(la) \
  (la == 'a' || la == 'b' || la == 'c' || la == 'd' || la == 'e' || la == 'g' || la == 'h' || la == 'k' || la == 'l' || la == 'm' || la == 'n' || la == 'o' || la == 'p' || la == 'r' || la == 's' || la == 't' || la == 'u')

// Keyword classification: sets `kind` to one of the KwKind values.
//   KW_NONE       — not a statement keyword (a plain bareword / autoquote key)
//   KW_ALWAYS     — always a statement keyword (package, use, no, class, role)
//   KW_NEEDS_NAME — only a declaration if followed by a name (sub, method)
// Unlike a bare match this never returns: the caller decides what to do with a
// non-keyword, which may still be a fat-comma autoquote key.
#define KEYWORD_MATCH(word, kind) do { \
    if (strcmp(word, "package") == 0 || strcmp(word, "use") == 0 || strcmp(word, "no") == 0 || strcmp(word, "class") == 0 || strcmp(word, "role") == 0) { \
      (kind) = KW_ALWAYS; \
    } else if (strcmp(word, "sub") == 0 || strcmp(word, "method") == 0) { \
      (kind) = KW_NEEDS_NAME; \
    } else { \
      (kind) = KW_NONE; \
    } \
  } while(0)