Max Brunsfeld
f620843591
Remove unused ReusableNode function
2018-05-08 11:42:15 -07:00
Max Brunsfeld
e8cfb9ced0
Remove incorrect return statement
...
This prevented conflicts between some tokens from being recorded
properly. In the case of JavaScript, it prevented tree-sitter from
recognizing the conflict between the forward slash operator and the
regex token, allowing regexes to be merged into parse states containing
'/' incorrectly.
Refs tree-sitter/tree-sitter-javascript#71
2018-04-17 17:14:36 -07:00
Max Brunsfeld
f00d2ade46
Remove unused function
2018-04-09 19:37:53 -07:00
Max Brunsfeld
b0b8279c14
Preallocate tree arrays when popping from the stack
2018-04-09 18:14:17 -07:00
Max Brunsfeld
3672a8ad87
Remove unused tree method
2018-04-09 12:29:22 -07:00
Max Brunsfeld
33820253e8
Make stack_print_dot_graph function take a language as an argument
2018-04-09 12:29:22 -07:00
Max Brunsfeld
379a2fd121
Incrementally build a tree of skipped tokens
...
Rather than pushing them to the stack individually
2018-04-09 12:29:22 -07:00
Max Brunsfeld
a79a8c216f
Include each node count and error cost in stack dot graphs
2018-04-06 16:10:36 -07:00
Max Brunsfeld
87098760de
🎨
2018-04-06 13:51:31 -07:00
Max Brunsfeld
94ed1b6964
Make array_splice take an array, not a pointer and length
2018-04-06 13:29:43 -07:00
Max Brunsfeld
09be0b6ef5
Store trees' children in TreeArrays, not w/ separate pointer and length
2018-04-06 13:26:18 -07:00
Max Brunsfeld
a6cf2e87e7
Fix halt_on_error tests
2018-04-06 13:26:18 -07:00
Max Brunsfeld
34349f9cbb
Put back limit on error handling based on accepted tree count
2018-04-06 13:26:18 -07:00
Max Brunsfeld
0ec7e5ce42
Remove ts_stack_force_merge function
2018-04-06 13:26:18 -07:00
Max Brunsfeld
1d9d6f37ad
Introduce an error cost per error instance to favor fewer errors
2018-04-06 13:26:18 -07:00
Max Brunsfeld
80f856cef5
Maintain a total node count on every tree
...
This simplifies (and fixes bugs in) the parse stack's tracking of its
total node count since the last error, which is needed for error
recovery.
2018-04-06 13:26:18 -07:00
Max Brunsfeld
f3bbf045b7
Avoid unnecessary stack node retain and release on every push
2018-04-06 13:26:18 -07:00
Max Brunsfeld
e59558c83b
Allow stack versions to be temporarily paused
...
This way, when detecting an error, we can defer the decision about
whether to bail or recover until all stack versions are processed.
2018-04-06 13:26:18 -07:00
Max Brunsfeld
1109a565fc
Merge pull request #159 from Pike/test-escape-brackets
...
Tests for issue 158
2018-04-06 13:19:36 -07:00
Max Brunsfeld
1ca261c79b
Fix some regex parsing bugs
...
* Allow escape sequences to be used in ranges
* Don't give special meaning to dashes outside of character classes
2018-04-06 12:46:06 -07:00
Max Brunsfeld
65e654ea9b
Remove overly conservative check for the validity of keyword capture tokens
2018-04-05 13:25:16 -07:00
Pieter Goetschalckx
3d0ca31cf1
Add error message for TSCompileErrorTypeInvalidTokenContents
2018-03-30 21:12:09 +02:00
Max Brunsfeld
dbe77e7199
Simplify testing-only ts_stack_iterate function
2018-03-29 17:50:07 -07:00
Max Brunsfeld
5520983144
Clean up Stack API
...
* Remove StackPopResult
* Rename top_state() -> state()
* Rename top_position() -> position()
* Improve docs
2018-03-29 17:37:54 -07:00
Max Brunsfeld
ee995c3d6b
Avoid redundant retains/releases by giving ts_stack_push move semantics
2018-03-29 17:18:43 -07:00
Max Brunsfeld
fb348c0f1e
Fix signed/unsigned comparison warning
2018-03-28 11:04:49 -07:00
Max Brunsfeld
e917756ad1
Remove depends_on_lookahead field from parse table entries
...
This simplifies the logic for determining whether a token is reusable
and makes it more conservative. It should fix some incremental parsing
bugs that are being caught by the randomized tests on CI.
2018-03-28 10:58:33 -07:00
Max Brunsfeld
186f70649c
Consolidate the unify for detecting conflicting tokens
2018-03-28 10:03:09 -07:00
Max Brunsfeld
a8bc67ac42
Allow LookaheadSet::for_each to terminate early
2018-03-28 10:03:09 -07:00
Max Brunsfeld
43e14332ed
Avoid creating duplicate metadata rules
2018-03-28 10:03:09 -07:00
Max Brunsfeld
b7d0606fbd
Be less conservative in merging parse states with external tokens
...
Also, clean up the internal representation of external tokens
2018-03-16 16:00:40 -07:00
Max Brunsfeld
7183f8d3e7
Fix unit reduction elimination bugs
...
* Handle 'chains' of unit reductions starting in a single state
* Avoid eliminating rules which will later receive aliases
2018-03-12 07:54:18 -07:00
Max Brunsfeld
72849787b1
Fix logic for identifying keyword capture token
2018-03-12 07:52:57 -07:00
Max Brunsfeld
0810971f3e
🔥 symbol iterator API
...
This idea was never fully baked.
2018-03-08 14:16:37 -08:00
Max Brunsfeld
128edbebd6
Eliminate non-user-visible unit reductions from parse tables
2018-03-08 12:53:32 -08:00
Max Brunsfeld
e927d02f43
Allow reusing leaf nodes unless the next leaf has changes
2018-03-07 17:44:54 -08:00
Max Brunsfeld
53cd89c614
Ensure keyword capture tokens aren't too loosely defined
2018-03-07 14:46:11 -08:00
Max Brunsfeld
c0cc35ff07
Create separate lexer function for keywords
2018-03-07 12:00:26 -08:00
Max Brunsfeld
f96969738b
Don't remove mergeable stack versions so aggressively during condense
2018-03-05 10:40:05 -08:00
Max Brunsfeld
dbc0c208f4
Add missing initialization of parser's in_ambiguity state
2018-03-02 15:25:39 -08:00
Max Brunsfeld
52087de4f0
Remove the concept of fragile reductions
...
They were a vestige of when Tree-sitter did sentential form-based
incremental parsing (as opposed to simply state matching). This was
elegant but not compatible with GLR as far as I could tell.
2018-03-02 14:51:54 -08:00
Max Brunsfeld
82c7e170b3
Fix case where loop was created in the parse stack
...
Fixes #133
2018-03-02 09:05:20 -08:00
Max Brunsfeld
32ef3e001a
Account for epsilon external tokens when merging parse states
...
Do not merge a token T into a parse state S if S contains
external tokens that can be *followed* by tokens that could
be shadowed by T.
At this point, the only automated test for this logic is via
the bash grammar, in which the `]` token should not be merged
into states in which `_concat` is valid, because `_concat`
can be followed by a `_special_characters` token, and `]`
would shadow `_special_characters`.
2018-02-28 14:47:04 -08:00
Max Brunsfeld
10a3cbd814
Move grammar schema to src folder
...
Now that there's a docs folder that contains actual docs.
2018-02-26 00:40:20 -08:00
Max Brunsfeld
16a45d4aa4
Fix hole in logic for terminating tree balancing
...
It's important that the repetition nodes have a child count of 2,
because we assign to their second child. We could maybe generalize
this to allow balancing in the presence of 'extra' nodes like comments
and errors, but this might be complicated.
2018-02-16 12:44:30 -08:00
Max Brunsfeld
2daae48fe0
Handle conflicts in repeat rules after external tokens
...
Signed-off-by: Rick Winfrey <rewinfrey@github.com>
2018-02-14 11:24:51 -08:00
Max Brunsfeld
facafcd6e4
Pass row/column position to input seek method
2018-02-14 07:31:49 -08:00
Max Brunsfeld
134c455b80
Simplify logic for terminating tree balancing
2018-02-12 12:13:21 -08:00
Max Brunsfeld
299a146b66
Balance repetition trees after parsing
2018-02-12 11:41:56 -08:00
Max Brunsfeld
8c29841adf
Represent repetitions with associative structure
2018-02-12 11:41:56 -08:00