Commit graph

291 commits

Author SHA1 Message Date
Amaan Qureshi
b40839cd72 style: prefer turbofish syntax where possible 2024-02-19 16:00:50 -05:00
Amaan Qureshi
d95fcc83b9 fix: remove redundant imports 2024-02-19 06:36:48 -05:00
Amaan Qureshi
5b299eafe5
fix: don't throw an error if the user uses map in the grammar 2024-02-18 00:26:14 -05:00
Amaan Qureshi
da1f890752 chore: error out when multiple arguments are passed to token/token.immediate 2024-02-17 01:26:44 -05:00
Amaan Qureshi
8dd65ccbc0 refactor: &PathBuf -> &Path 2024-02-17 00:45:28 -05:00
Amin Yahyaabadi
51c147053e
feat: error out if an empty string is in the extras array
This prevents never-ending loops in the parser
2024-02-13 15:00:48 -05:00
Amaan Qureshi
5ea0dbf77a chore: some more clippy lints 2024-02-13 03:33:07 -05:00
Amaan Qureshi
3da79ba2b6 fix: update schema for regex flags 2024-02-12 15:39:14 -05:00
Amaan Qureshi
ce5f5fffc1 chore(generate): dedup and warn about duplicate or invalid rules 2024-02-11 01:28:31 -05:00
Amaan Qureshi
78ccc39ca9
fix: properly error out when the word property is an invalid rule 2024-02-11 00:37:23 -05:00
Amaan Qureshi
3d68ca4583 fix: inherited grammar generation 2024-02-10 18:25:35 -05:00
dundargoc
df1fe842eb docs: various fixes
Closes https://github.com/tree-sitter/tree-sitter/issues/1317.
Closes https://github.com/tree-sitter/tree-sitter/issues/1752.
Closes https://github.com/tree-sitter/tree-sitter/issues/2439.

Co-authored-by: Simon Hengel <sol@typeful.net>
Co-authored-by: Akash Yadav <itsaky01@gmail.com>
Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
Co-authored-by: Laytan Laats <laytanlaats@hotmail.com>
2024-02-08 00:08:59 +01:00
Amaan Qureshi
767db31114
fix: remove redundant code 2024-02-07 07:13:03 -05:00
Amaan Qureshi
993ee75d8c
fix: don't add extraneous exports to the json and add missing rules to the schema 2024-02-07 07:10:51 -05:00
Amaan Qureshi
59be1edaa1
refactor: swap &Vec[T] with &[T] where appropriate 2024-02-07 02:50:31 -05:00
dundargoc
c8bd6705cf
chore: clippy 2024-02-06 23:34:14 -05:00
root
b7d48b48fd
chore(cli): update to regex-syntax 0.8
regex-syntax has restructured the Ast enum a bit, rather than having a Class
member it now has seperate members for different types of Class.
2024-02-05 01:22:09 -05:00
Amaan Qureshi
000c2f4dec
feat: allow the grammar to log to stdout 2024-02-05 00:46:34 -05:00
Amaan Qureshi
04ff704bca
chore(cli): apply clippy fixes 2024-02-04 04:18:48 -05:00
Andrew Hlynskyi
d56b51a11d
Revert "Alt #2454" 2023-11-29 11:20:05 +02:00
Andrew Hlynskyi
60779cc1ac fix(gen): parser.c should include parser.h relatively 2023-08-26 20:57:08 +03:00
Amaan Qureshi
6d41d99990
Merge pull request #2559 from amaanq/silent-ignore-u
fix: ignore regex u flag
2023-08-25 19:25:15 -04:00
Amaan Qureshi
6969766664 fix: ignore regex u flag
It's needed for certain regex patterns in JS, and we can just silently ignore it.
2023-08-25 19:23:08 +03:00
Andrew Hlynskyi
b3fef28a10 chore(gen): add parser.c enum names to be better discoverable 2023-08-25 19:11:42 +03:00
Andrew Hlynskyi
fbfa58edc8 chore(gen): move external scanner stuff closer to the end of parser.c 2023-08-25 19:11:42 +03:00
Andrew Hlynskyi
683fe442e4 fix(gen): cycle between aliases and anonymous symbols
An example of an error cycle in a `parser.c`:

```
static const TSSymbol ts_symbol_map[] = {
  ...
  [anon_sym_RBRACE] = anon_sym_RBRACE2,
  [anon_sym_RBRACE2] = anon_sym_RBRACE,
  ...
};
```
2023-08-23 16:51:05 +03:00
Amaan Qureshi
e0434327d0
fix(render): only output SPACE for strings that are just a space 2023-08-16 13:44:44 -04:00
Amaan Qureshi
2d0a3d647b
Merge pull request #2491 from amaanq/sanitize
fix: replace & sanitize more characters
2023-08-13 20:15:20 -04:00
Amaan Qureshi
0b1b0d2fb7
fix: replace & sanitize more characters 2023-08-13 19:29:37 -04:00
Amaan Qureshi
318d4a705a fix: don't add flags if they're not present 2023-08-13 16:28:03 -04:00
Amaan Qureshi
dee98e06e9
Merge pull request #2474 from amaanq/case-insensitive
feat!: support the case-insensitive regex flag
2023-08-11 23:12:15 -04:00
Andrew Hlynskyi
4a007259fc Fix warning from #2454 in more clear way 2023-08-10 03:59:34 +03:00
Amaan Qureshi
f35752e3ac
feat!: support the case-insensitive regex flag 2023-08-06 23:40:29 -04:00
Amaan Qureshi
96919cae5d
fix(generate): add Vertical Tab and Form Feed to the whitespace class 2023-08-06 20:41:09 -04:00
Jake Sarjeant
61b70943b1 feat(cli): add option to select JS runtime other than node 2023-08-03 21:34:47 +03:00
Amaan Qureshi
b8fe5fe21b fix: do not allow eof to advance states if the new state is the same state 2023-08-02 10:47:27 +01:00
Andrew Hlynskyi
a2f834d846 More error contexts + conv panics to errors with context 2023-07-30 21:16:45 +03:00
Amaan Qureshi
f4e788b28e
feat: warn when unused conflicts are present in a grammar 2023-07-28 00:23:28 -04:00
Amaan Qureshi
c521e9c18e
chore: improve error message in some spots loading grammar.json 2023-07-24 00:44:44 -04:00
Amaan Qureshi
5fba369c4a
fix: disallow inlining the first rule
This prevents a panic when indexing symbol_ids during the generation process
2023-07-19 16:14:58 -04:00
Andrew Hlynskyi
0b0cc6c429 Fix rustc 1.71.0 warnings 2023-07-13 17:50:04 +03:00
Andreas Deininger
0751736d17 docs: convert various links to https protocol 2023-04-04 18:05:46 +03:00
Max Brunsfeld
6b87326470
Merge pull request #1787 from kianmeng/fix-typos
Fix typos
2022-08-25 10:25:39 -07:00
Nat Mote
4e3179fbc0
Avoid extracting default alias for extras
Fixes #1834
2022-08-10 07:27:34 -07:00
Kian-Meng Ang
b8552ec6c4 Fix typos 2022-06-28 19:57:42 +08:00
Max Brunsfeld
4b93326898 Don't generate primary states array if it will be unused due to abi version setting 2022-03-02 14:57:59 -08:00
Max Brunsfeld
9866674cf8
Merge pull request #1660 from alex-pinkus/expanded-regex-support
Expand regex support to include emojis and binary ops
2022-02-24 17:14:23 -08:00
Alex Pinkus
8fadf18655 Expand regex support to include emojis and binary ops
The `Emoji` property alias is already present, but the actual property
is not available since it lives in a new file. This adds that file to
the `generate-unicode-categories-json`.

The `emoji-data` file follows the same format as the ones we already
consume in `generate-unicode-categories-json`, so adding emoji support
is fairly easy. his, grammars would need to hard-code a set of
unicode ranges in their own regex. The Javascript library `emoji-regex`
cannot be used because of #451.

For unclear reasons, the characters #, *, and 0-9 are marked as
`Emoji=Yes` by `emoji-data.txt`. Because of this, a grammar that wishes
to use emojis is likely to want to exclude those characters. For that
reason, this change also adds support for binary operations in regexes,
e.g. `[\p{Emoji}&&[^#*0-9]]`.

Lastly (and perhaps controversially), this change introduces new
variables available at grammar compile time, for the major, minor, and
patch versions of the tree-sitter CLI used to compile the grammar. This
will allow grammars to conditionally adopt these new regex features
while remaining backward compatible with older versions of the CLI.
Without this part of the change, grammar authors who do not precompile
and check-in their `grammar.json` would need to wait for downstream
systems to adopt a newer tree-sitter CLI version before they could begin
to use these features.
2022-02-19 11:41:36 -08:00
Max Brunsfeld
994cb61f2c Always generate parser.h, regardless of chosen ABI version
For some ABI changes, we may need to make changes to the parser.h in order
to restore a previous binary format, but for the current range of supported
ABI versions (13 + 14), the current parser.h is fine.

Refs #1599
2022-01-23 10:29:52 -08:00
Max Brunsfeld
82ceebc10d 🎨 Use base struct syntax to clean up grammar expectations 2022-01-20 17:17:46 -08:00