Commit graph

179 commits

Author SHA1 Message Date
Max Brunsfeld
8a13b5d120 Rename StackPopResult -> StackSlice 2016-03-03 10:16:10 -08:00
Max Brunsfeld
aef7582a2a Start using the forward move to recover from errors
Some unit tests passing. Corpus tests still failing
2016-03-02 21:08:42 -08:00
Max Brunsfeld
e0c24e3be6 Remove old error recovery code 2016-03-02 20:58:39 -08:00
Max Brunsfeld
5a34d74702 Clean up stack 2016-02-25 21:51:39 -08:00
Max Brunsfeld
1850951b4f Escape special chars in production names for debug graphs 2016-02-24 17:24:11 -08:00
Max Brunsfeld
da2ef7ad35 Store trees in the links between stack nodes, not in the nodes themselves 2016-02-23 17:35:50 -08:00
Max Brunsfeld
b36143d7a7 Add flag for logging dot graphs of the stack while parsing 2016-02-23 09:45:27 -08:00
Max Brunsfeld
6dd92c3abe Add function for rendering the stack as a DOT graph 2016-02-23 00:08:55 -08:00
Max Brunsfeld
b113dc8b0f Return a TreeArray from ts_stack_pop
Since the capacity is now included in the return value, the buffer
can be reused in the ts_parser__accept function. Also, it's just
cleaner to use Array consistently, rather than a separate buffer
and size.
2016-02-21 22:31:13 -08:00
Max Brunsfeld
3d7df851b5 Rename Vector -> Array 2016-02-17 20:41:29 -08:00
Max Brunsfeld
6fa7eca966 Make vector struct type-safe 2016-02-17 15:30:47 -08:00
Max Brunsfeld
3f08bfb264 Fix build warnings 2016-02-12 14:11:11 -08:00
Max Brunsfeld
e90a425618 Only return one result for each revealed head from ts_stack_pop 2016-02-08 12:08:15 -08:00
Max Brunsfeld
c96c4a08e6 Use an object pool for stack nodes, to reduce allocations
Also, fix some leaks in the case where memory allocation failed during parsing
2016-02-04 11:19:42 -08:00
Max Brunsfeld
7c44b0e387 Fix leaked lookahead trees in normal parsing 2016-01-29 17:31:43 -08:00
Max Brunsfeld
5f27550a7a Fix leaked nodes in stack 2016-01-28 21:18:57 -08:00
Max Brunsfeld
3dde0a6f39 Handle allocation failures during parsing 2016-01-19 18:08:01 -08:00
Max Brunsfeld
1543a6c7b0 Handle allocation failures when instantiating documents 2016-01-18 11:32:10 -08:00
Max Brunsfeld
87316f22f3 Wrap all calls to malloc and friends 2016-01-15 15:27:50 -08:00
Max Brunsfeld
19b776e74d Fix some errors caught by clang static analyzer 2016-01-15 13:33:05 -08:00
Max Brunsfeld
da1bc038e5 Remove nested options structs in Tree 2015-12-22 14:20:58 -08:00
Max Brunsfeld
7fbb628c78 Remove TreeSelectionCallback struct
Just make a typedef for the function type
2015-12-17 12:09:06 -08:00
Max Brunsfeld
10286f307f Pass reference to parser in stack's tree selection callback 2015-12-08 12:21:27 -08:00
Max Brunsfeld
08d50c25ae clang-format 2015-12-04 20:56:33 -08:00
Max Brunsfeld
d2bf88d5fe Include rows and columns in TSLength
This way, we don't have to have separate 1D and 2D versions for so many values
2015-12-04 20:20:29 -08:00
Max Brunsfeld
863cabc827 Don't include trailing ubiquitous tokens as children when reducing 2015-12-02 15:31:15 -08:00
Max Brunsfeld
ce27c2ee97 🔥 variable accidentally left in for debugging 2015-11-20 13:12:32 -08:00
Max Brunsfeld
7aba2a0716 Rename DEBUG macro to LOG
DEBUG is already used as the symbol to enable/disable assert() calls
2015-11-20 11:50:50 -08:00
Max Brunsfeld
c88e9044d5 Make stack popping more robust 2015-11-20 00:04:21 -08:00
Max Brunsfeld
ab34cfecd9 Replace TreeVector with a more generic Vector struct 2015-11-15 09:55:36 -08:00
Max Brunsfeld
483577f00d Fix error when merging nodes at the base of the parse stack 2015-11-11 17:31:40 -08:00
Max Brunsfeld
f5d861a019 Fix bug where ts_stack_pop results were backwards for some stack configurations 2015-10-28 12:10:45 -07:00
Max Brunsfeld
500533476b Fix bugs in handling multiple simultaneous ambiguities 2015-10-22 11:42:38 -07:00
Max Brunsfeld
216ce8c80b Rename receiver parameter to 'self' 2015-10-14 22:14:08 -07:00
Max Brunsfeld
6254f45c1b Rename ParseStack -> Stack 2015-09-18 22:02:06 -07:00
Max Brunsfeld
b3d883e128 Store edits in trees, not by splitting stack
This allows for multiple edits per parse, though it is not exposed through
the API yet
2015-09-18 22:02:06 -07:00
Max Brunsfeld
f9b057f3a9 clang-format everything 2015-07-27 18:29:48 -07:00
Max Brunsfeld
80b8a0a9fb Rename stack_right_position -> stack_total_tree_size
I want to re-use the stack data structure for storing the
re-usable nodes from the previous parse tree during an edit.
In this case, the stack won't conceptually start at position
zero, so the name 'right_position' doesn't make sense.
2014-10-08 17:37:21 -07:00
Max Brunsfeld
26ac5788b6 Don't use struct literal syntax for TSLength 2014-09-26 16:31:36 -07:00
Max Brunsfeld
c1565c1aae Track AST nodes' sizes in characters as well as bytes
The `pos` and `size` functions for Nodes now return TSLength structs,
which contain lengths in both characters and bytes. This is important
for knowing the number of unicode characters in a Node.
2014-09-26 16:15:07 -07:00
Max Brunsfeld
545e575508 Revert "Remove the separator characters construct"
This reverts commit 5cd07648fd.

The separators construct is useful as an optimization. It turns out that
constructing a node for every chunk of whitespace in a document causes a
significant performance regression.

Conflicts:
	src/compiler/build_tables/build_lex_table.cc
	src/compiler/grammar.cc
	src/runtime/parser.c
2014-09-02 08:03:51 -07:00
Max Brunsfeld
5cd07648fd Remove the separator characters construct
Now, grammars can handle whitespace by making it another ubiquitous
token, like comments.

For now, this has the side effect of whitespace being included in the
tree that precedes it. This was already an issue for other ubiquitous
tokens though, so it needs to be fixed anyway.
2014-09-01 20:19:43 -07:00
Max Brunsfeld
25a254a732 Comment and format 2014-08-31 16:24:27 -07:00
Max Brunsfeld
85d8c9df5c Handle multiple ubiquitous in a row 2014-08-31 12:11:16 -07:00
Max Brunsfeld
e6bbab41e5 Realloc parse stack when it grows to its capacity 2014-08-30 21:39:55 -07:00
Max Brunsfeld
4327f3ed26 Refactor parser and stack 2014-08-09 01:03:55 -07:00
Max Brunsfeld
1e79ed794b Allow multiple top-level nodes
Now, the root node of a document is always a document node.
It will often have only one child node which corresponds to the grammar's
start symbol, but not always. Currently, it may have more than one child
if there are ubiquitous tokens such as comments at the beginning of the
document. In the future, it will also be possible be possible to have multiple
for the document to have multiple children if the document is partially parsed.
2014-08-09 00:00:20 -07:00
Max Brunsfeld
7ba3953f7e Simplify handling of ubiquitous tokens during reduce 2014-08-08 08:46:01 -07:00
Max Brunsfeld
eecbcccee0 Remove generated parsers' dependency on the runtime library
Generated parsers no longer export a parser constructor function.
They now export an opaque Language object which can be set on
Documents directly. This way, the logic for constructing parsers
lives entirely in the runtime. The Languages are just structs which
have no load-time dependency on the runtime
2014-07-30 23:40:02 -07:00
Max Brunsfeld
98cc2f2264 Auto-format all source code with clang-format 2014-07-21 13:20:00 -07:00