Commit graph

60 commits

Author SHA1 Message Date
Max Brunsfeld
f460b921e2 Fix off-by-one error in storing reusable right-subtree 2014-10-10 12:10:23 -07:00
Max Brunsfeld
4dcc712a8c Start work on re-using right side of parse tree 2014-10-09 19:58:15 -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
26f9e22193 Clean up parser code 2014-10-08 16:51:04 -07:00
Max Brunsfeld
af7f57a80e Fix sizing of error nodes after edits 2014-10-05 16:56:50 -07:00
Max Brunsfeld
6d37877e49 Tweak debugging output 2014-10-05 16:56:29 -07:00
Max Brunsfeld
78c5fe8e02 clang-format 2014-10-03 15:44:21 -07:00
Max Brunsfeld
5dd8778996 Clean up Parser handle_error function 2014-09-29 10:33:56 -07:00
Max Brunsfeld
10a3251fbe Remove index parameter from STACK_FROM_TOP macro 2014-09-29 10:16:24 -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
e23f11b7c4 Allow lexical debug mode to be enabled on documents
- `ts_document_set_debug(doc, 1)` implies parse debug mode
- `ts_document_set_debug(doc, > 1)` implies parse and lex debug mode
2014-09-11 13:12:06 -07:00
Max Brunsfeld
8512af712e Add debug log when re-lexing during error handling 2014-09-05 18:38:17 -07:00
Max Brunsfeld
6cf267efaf Clean up breakdown stack function 2014-09-03 22:35:52 -07:00
Max Brunsfeld
3dea1261a6 Clean up document specs for incremental parsing 2014-09-03 18:48:10 -07:00
Max Brunsfeld
c72445d808 Fix inc parsing for nodes containing ubiq tokens 2014-09-03 13:17:06 -07:00
Max Brunsfeld
ad52bdc448 Fix inc parsing when appending to end of a token 2014-09-03 07:09:15 -07:00
Max Brunsfeld
cc5f1471a8 Add debug lines for breaking down stack when re-parsing 2014-09-02 22:16:17 -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
e941f8c175 Fix error in document editing
When breaking down the stack in parser.c, the previous code
would not account for ubiquitous tokens. This was a problem
for a long time, but wasn't noticed until ubiquitous tokens
started being used to represent separator characters
2014-09-01 21:32:29 -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
88d07c8960 Clean up parse table lookup function 2014-08-31 21:17:32 -07:00
Max Brunsfeld
2985a98150 Build error nodes in lexer again, not in parser 2014-08-31 16:59:01 -07:00
Max Brunsfeld
16d5cf1d04 Remove expected symbols from error nodes 2014-08-31 16:39:16 -07:00
Max Brunsfeld
85d8c9df5c Handle multiple ubiquitous in a row 2014-08-31 12:11:16 -07:00
Max Brunsfeld
c5ac02c571 Fix size calculation for error nodes 2014-08-29 13:22:03 -07:00
Max Brunsfeld
604b149c4b Assign sizes to error nodes in handle_error 2014-08-28 18:35:30 -07:00
Max Brunsfeld
0193be166b Fix overridden initializer warning in tree constructor 2014-08-27 22:06:27 -07:00
Max Brunsfeld
b91f48ced2 Call handle_error even when error occurs exactly where expected
Previously, if an error happened right at the beginning of an error
production, the error node would be immediately shifted onto the stack
without calling the error handling function.
2014-08-27 18:44:27 -07:00
Max Brunsfeld
e0a53b9f14 Make parse and lex debug output more readable 2014-08-27 18:27:53 -07:00
Max Brunsfeld
bd145d2c6a Preserve the initial error node in handle_error function 2014-08-26 23:22:18 -07:00
Max Brunsfeld
b71d0f7f9d Remove untested, unused error handling for reduce_extra action 2014-08-26 22:22:09 -07:00
Max Brunsfeld
0470b34f2f Clean up build_error_node function 2014-08-26 08:40:21 -07:00
Max Brunsfeld
77941c85ff Avoid building incomplete error nodes during lexing
The lexer doesn't know the expected symbols, so it doesn't have enough
information to construct error nodes. Now, when it encounters an invalid
character, it returns NULL and the parser builds a correct error node.
2014-08-25 23:35:00 -07:00
Max Brunsfeld
c04474acf6 Format comments consistently in parser.c 2014-08-25 23:02:43 -07:00
Max Brunsfeld
826d4dfa23 Clean up handle_error function 2014-08-25 23:00:24 -07:00
Max Brunsfeld
2318691e28 Move newline in debugging output 2014-08-25 21:23:29 -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
412cc93812 clang format 2014-07-31 13:11:39 -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
Max Brunsfeld
df359bc01f Use 2-space indent in c files 2014-07-20 20:27:33 -07:00
Max Brunsfeld
779bf0d745 Don't store tree's hidden children in a separate array
Just mark hidden trees as such, and skip them when
pretty-printing a tree
2014-07-17 13:36:53 -07:00
Max Brunsfeld
25f927e321 Remove unnecessary accessor functions for tree 2014-07-14 21:11:15 -07:00
Max Brunsfeld
6e551d6d9f Simplify handling of multiple top-level nodes after parsing 2014-07-14 20:46:20 -07:00
Max Brunsfeld
9da7663e99 Combine TSParser and TSStateMachine objects
My original thought was to decouple the runtime from
the LR parser generator by making TSParser a generic
interface that LR parsers implement.

I think this was more trouble than it was worth.
2014-07-10 13:23:20 -07:00
Max Brunsfeld
963768eb8a Remove unnecessary parser helper functions 2014-05-09 15:03:29 -07:00
Max Brunsfeld
0d6435e24a Pass edit information into parser function 2014-03-15 16:55:35 -07:00