Max Brunsfeld
513edec7c1
Merge pull request #77 from philipturnbull/scan-build-fixes
...
Fix errors found by scan-build
2017-06-20 10:15:20 -07:00
Phil Turnbull
cfca764d48
Root can never be NULL in this context
2017-06-15 07:47:16 -04:00
Max Brunsfeld
b862db766e
Merge remote-tracking branch 'origin/master' into update-fixture-grammars
2017-06-14 17:11:44 -07:00
Phil Turnbull
d1b19e8196
Prevent NULL pointer dereference in parser__accept
...
parser__select_tree can return true if 'left != NULL' and 'right == NULL' which
will later cause a NULL ptr deref:
src/runtime/parser.c:842:14: warning: Access to field 'ref_count' results in a dereference of a null pointer (loaded from variable 'root')
assert(root->ref_count > 0);
^~~~~~~~~~~~~~~
2017-06-14 11:12:06 -04:00
Phil Turnbull
da099d0bbe
Prevent NULL pointer dereference in parser__repair_error_callback
...
Because repair_reduction_count is unsigned, the default of '-1' is 0xffffffff
and will cause the loop to be entered if repair_reduction_count is NULL:
src/runtime/parser.c:691:11: warning: Dereference of null pointer
if (repair_reductions[j].params.symbol == repair->symbol) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-06-14 11:12:06 -04:00
Max Brunsfeld
e8a9bb7a51
🎨 Extract parser__halt_parse function
2017-05-01 14:41:55 -07:00
Max Brunsfeld
74f5ceddf7
Fix parsing of valid code with halt_on_error flag set
...
Signed-off-by: Tim Clem <timothy.clem@gmail.com>
2017-05-01 14:25:25 -07:00
Max Brunsfeld
a98d449d88
Add an option to immediately halt on syntax error
2017-05-01 13:50:49 -07:00
Max Brunsfeld
1f908324dc
Prevent infinite loop in skip_preceding_trees error recovery strategy
2017-03-21 12:14:44 -07:00
Max Brunsfeld
ed31e82ee6
Skip empty tokens when recovering from errors
2017-03-19 22:20:59 -07:00
Max Brunsfeld
d222dbb9fd
Allow lexer to accept tokens that ended at previous positions
...
* Track lookahead in each tree
* Add 'mark_end' API that external scanners can use
2017-03-13 17:06:52 -07:00
Max Brunsfeld
df520635c6
Prevent crash due to huge number of possible paths through parse stack
2017-02-20 14:34:10 -08:00
Max Brunsfeld
c14a776a3d
Avoid including trailing extra tokens within error nodes unnecessarily
2017-02-19 21:21:54 -08:00
Max Brunsfeld
93d7a75b09
Suppress one unnecessary type of error recovery variation
...
If we already have a stack version in which, for example,
a `function_call` is skipped, don't create another stack
version in which that `function_call` is reduced to an
`expression`, and then the `expression` is skipped. That
doesn't improve the error recovery at all, but adds to the
branching factor of the parse stack and makes things harder
to debug.
2017-02-07 22:07:56 -08:00
Max Brunsfeld
b01c5404eb
Ensure error_end_position variable is initialized
2017-02-07 17:48:53 -08:00
Max Brunsfeld
343887c1dd
Fix miscounting of extra tokens when repairing errors
2017-02-06 17:43:07 -08:00
Max Brunsfeld
672d491775
Fix errors in management of external scanner's most recent state
2017-01-30 22:04:46 -08:00
Max Brunsfeld
36608180d2
Store external token states in the parse stack
2017-01-08 22:06:05 -08:00
Max Brunsfeld
3a4daace26
Move reusable node functions to their own file
2017-01-05 10:07:27 -08:00
Max Brunsfeld
2fa7b453c8
Restore external scanner's state only after repositioning lexer
...
Also, properly identify the leaf node with the external token state
2016-12-21 13:59:56 -08:00
Max Brunsfeld
34a65f588d
Tweak naming and organization of external-scanner related language fields
2016-12-21 11:24:41 -08:00
Max Brunsfeld
e6c82ead2c
Start work toward maintaining external scanner's state during incremental parses
2016-12-20 17:06:20 -08:00
Max Brunsfeld
2b3da512a4
Add serialize, deserialize and reset callbacks to external scanners
...
Signed-off-by: Nathan Sobo <nathan@github.com>
2016-12-20 13:12:01 -08:00
Max Brunsfeld
7f6ec0131d
Remove duplication between parser_destroy and parser_set_language
2016-12-06 10:12:49 -08:00
Max Brunsfeld
c4fe8ded95
Remove state argument to Lexer advance method
2016-12-05 16:36:34 -08:00
Max Brunsfeld
c16b6b2059
Run external scanners during error recovery
2016-12-05 11:50:24 -08:00
Max Brunsfeld
cf0d8abea1
Destroy external scanner when destroying Parser
2016-12-04 14:18:30 -08:00
Max Brunsfeld
0f8e130687
Call external scanner functions when lexing
2016-12-02 22:03:48 -08:00
Max Brunsfeld
c966af0412
Start work on external tokens
2016-12-02 16:24:19 -08:00
Max Brunsfeld
e7217f1bac
Clean up some methods in parser.c
2016-11-14 17:25:55 -08:00
Max Brunsfeld
535879a2bd
Represent byte, char and tree counts as 32 bit numbers
...
The parser spends the majority of its time allocating and freeing trees and stack nodes.
Also, the memory footprint of the AST is a significant concern when using tree-sitter
with large files. This library is already unlikely to work very well with source files
larger than 4GB, so representing rows, columns, byte lengths and child indices as
unsigned 32 bit integers seems like the right choice.
2016-11-14 12:19:13 -08:00
Max Brunsfeld
8edb8df530
Remove extraneous Language methods
2016-11-14 10:35:33 -08:00
Max Brunsfeld
1118a9142a
Introduce Symbol::Index type alias
2016-11-14 10:25:26 -08:00
Max Brunsfeld
1fddb124b3
Remove stray LOG_STACK() call
2016-11-14 09:32:05 -08:00
Max Brunsfeld
fad7294ba4
Store shift states for non-terminals directly in the main parse table
2016-11-14 08:36:06 -08:00
Max Brunsfeld
8d9c261e3a
Don't include reduce actions for nonterminal lookaheads
2016-11-10 11:33:37 -08:00
Max Brunsfeld
c9dcb29c6f
Remove the TS prefix from some internal type/function names
2016-11-09 20:59:05 -08:00
Max Brunsfeld
4106ecda43
Remove logic for recovering from OOM
2016-11-04 09:18:38 -07:00
Max Brunsfeld
e53beb66c9
Avoid anonymous nested struct to silence override-init warnings
2016-10-26 11:10:56 -07:00
Max Brunsfeld
eed54d95e1
Merge branch 'master' into changed-ranges
2016-10-16 21:10:25 -07:00
Max Brunsfeld
b3140b2689
Implement ts_document_parse_and_get_changed_ranges
2016-10-15 22:31:21 -07:00
Max Brunsfeld
e149d94ff5
Remove generated parsers' dependency on runtime.h
2016-10-05 14:02:49 -07:00
Max Brunsfeld
3014101104
Fix inconsistencies in nodes sizes after edits
2016-09-19 13:35:08 -07:00
Max Brunsfeld
fcf9293d35
Use explicit stack for assigning trees' parent pointers
2016-09-19 12:40:45 -07:00
Max Brunsfeld
00528e50ce
Change edit API to be byte-based
2016-09-13 13:08:52 -07:00
Max Brunsfeld
cc62fe0375
Represent Lengths in terms of Points
2016-09-09 21:11:02 -07:00
Max Brunsfeld
096ac2d4b6
Rename ts_document_set_debugger -> ts_document_set_logger
2016-09-06 17:40:26 -07:00
Max Brunsfeld
587bbe998c
Don't reuse non-trivial subtrees when stack is split
2016-09-06 10:23:26 -07:00
Max Brunsfeld
b76574e01c
Handle ambiguities between extra and non-extra tokens using normal GLR splitting
2016-09-06 10:22:16 -07:00
Max Brunsfeld
4f0c83ba01
Move logic for lexical error handling outside of lexer functions
...
This way, less logic needs to be exposed in parser.h
2016-09-03 23:40:57 -07:00