tree-sitter-zsh 0.39.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-zsh",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "description": "Zsh grammar for tree-sitter",
5
5
  "repository": "https://github.com/geohar/tree-sitter-zsh",
6
6
  "license": "MIT",
package/src/scanner.c CHANGED
@@ -966,15 +966,11 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
966
966
  "valid_symbols[CONCAT]=%d, lookahead='%c'\n",
967
967
  valid_symbols[CONCAT], lexer->lookahead);
968
968
  #endif
969
- if (!valid_symbols[CONCAT] &&
970
- (lexer->lookahead == ' ' || lexer->lookahead == '\t')) {
969
+ if (!valid_symbols[CONCAT] && iswspace(lexer->lookahead)) {
971
970
  #if DEBUG
972
971
  fprintf(stderr, "SCANNER: BARE_DOLLAR skipping whitespace\n");
973
972
  #endif
974
- while ((lexer->lookahead == ' ' || lexer->lookahead == '\t') &&
975
- !lexer->eof(lexer)) {
976
- skip(lexer);
977
- }
973
+ skip_wsnl(lexer);
978
974
  }
979
975
 
980
976
  if (lexer->lookahead == '$') {
@@ -1805,20 +1801,14 @@ regex:
1805
1801
  }
1806
1802
  }
1807
1803
 
1804
+ #if DEBUG
1805
+ fprintf(stderr, "DEBUG: regex scan start\n");
1806
+ #endif
1807
+
1808
1808
  lexer->mark_end(lexer);
1809
1809
 
1810
1810
  State state = {false, false, false, false, false, 0, 0, 0};
1811
1811
  while (!state.done) {
1812
- if (state.in_single_quote) {
1813
- if (lexer->lookahead == '\'') {
1814
- state.in_single_quote = false;
1815
- advance(lexer);
1816
- lexer->mark_end(lexer);
1817
-
1818
- // Track entering parameter expansion context
1819
- enter_context(scanner, CTX_RAW_STRING); // FIXME!
1820
- }
1821
- }
1822
1812
  switch (lexer->lookahead) {
1823
1813
  case '\\':
1824
1814
  state.last_was_escape = true;
@@ -1862,8 +1852,26 @@ regex:
1862
1852
  break;
1863
1853
  case '\'':
1864
1854
  // Enter or exit a single-quoted string.
1865
- state.in_single_quote = !state.in_single_quote;
1855
+ if (state.in_single_quote) {
1856
+ state.in_single_quote = false;
1857
+ #if DEBUG
1858
+ fprintf(stderr, "DEBUG: regex scan exit raw string\n");
1859
+ #endif
1860
+
1861
+ // Track entering parameter expansion context
1862
+ exit_context(scanner, CTX_RAW_STRING);
1863
+ } else {
1864
+ state.in_single_quote = true;
1865
+ #if DEBUG
1866
+ fprintf(stderr, "DEBUG: regex scan entering raw string\n");
1867
+ #endif
1868
+
1869
+ // Track entering parameter expansion context
1870
+ enter_context(scanner, CTX_RAW_STRING);
1871
+
1872
+ }
1866
1873
  advance(lexer);
1874
+ lexer->mark_end(lexer);
1867
1875
  state.advanced_once = true;
1868
1876
  state.last_was_escape = false;
1869
1877
  continue;
@@ -1964,6 +1972,10 @@ regex:
1964
1972
  return false;
1965
1973
  }
1966
1974
 
1975
+ #if DEBUG
1976
+ fprintf(stderr, "DEBUG: regex scan returning regex\n");
1977
+ #endif
1978
+
1967
1979
  return true;
1968
1980
  }
1969
1981
  }
Binary file