Commit graph

6118 commits

Author SHA1 Message Date
Max Brunsfeld
604b149c4b Assign sizes to error nodes in handle_error 2014-08-28 18:35:30 -07:00
Max Brunsfeld
a72b79f7f3 Tweak formatting in node.c 2014-08-28 13:30:02 -07:00
Max Brunsfeld
3430a5edcc Clarify distinction btwn tree padding, tree offset, node position
- Node position is public. It represents the node's first character
  index in the document.
- Tree offset is private. It represents the distance between the tree's
  first character index and it's parent's first character index.
- Tree padding is private. It represents the amount of whitespace
  (or other separator characters) immediately preceding the tree.
2014-08-28 13:22:06 -07:00
Max Brunsfeld
226ffd6b5b Fix initializer list deduction warnings in specs 2014-08-27 22:23:45 -07:00
Max Brunsfeld
0193be166b Fix overridden initializer warning in tree constructor 2014-08-27 22:06:27 -07:00
Max Brunsfeld
9db291fe88 Fix missing initializer warning in document constructor 2014-08-27 21:45:46 -07:00
Max Brunsfeld
0414451d79 Fix missing comma between CC flags in tests gyp file 2014-08-27 21:34:42 -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
7b0a52ec26 Pretty-print single hidden tree nodes correctly 2014-08-27 12:56:36 -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
37d5db6fee Move newline in lexer debugging output 2014-08-26 22:21:21 -07:00
Max Brunsfeld
346cf4fe5d Remove LEX_PANIC macro 2014-08-26 13:12:12 -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
117869e49a Fix position calculation in node_find_for_range 2014-08-25 15:52:17 -07:00
Max Brunsfeld
1535ebd21c Handle null parent in {next,prev}_sibling 2014-08-25 11:28:09 -07:00
Max Brunsfeld
cef6827182 Add find_for_range function for Nodes 2014-08-25 09:31:27 -07:00
Max Brunsfeld
b1a7886225 Rename node_leaf_at_pos -> node_find_pos
It doesn't always return a leaf node, just the smallest node
that spans the given position.
2014-08-25 09:06:51 -07:00
Max Brunsfeld
8f4939a3d3 unsigned char -> uint32_t in CharacterRange 2014-08-24 01:05:59 -07:00
Max Brunsfeld
9338249075 Remove implicit CharacterRange constructors
Also fix misc smaller lint errors
2014-08-23 14:52:44 -07:00
Max Brunsfeld
0bb5663f0f Refactor - represent char sets in terms of inclusions and exclusions 2014-08-23 14:25:45 -07:00
Max Brunsfeld
6f374fddff Tweak format for pretty printing some classes 2014-08-23 13:52:00 -07:00
Max Brunsfeld
2963b08f79 Eliminate duplicates when constructing choice rules 2014-08-21 20:04:42 -07:00
Max Brunsfeld
fcdcdca303 Whitespace 2014-08-09 01:07:14 -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
9302080aa6 Remove unit test on parser
It wasn't adding any value
2014-08-09 00:00:20 -07:00
Max Brunsfeld
8da9219c3a Remove redundant functions for Documents
There's no need for a `string` function since one already
exists for Nodes.

Now the root node is always stored on the document. This
means callers of `ts_document_root_node` don't need to release
its return value.
2014-08-08 12:58:51 -07:00
Max Brunsfeld
7ba3953f7e Simplify handling of ubiquitous tokens during reduce 2014-08-08 08:46:01 -07:00
Max Brunsfeld
41c4e7cd8f Fix more namespace formatting 2014-08-08 08:35:26 -07:00
Max Brunsfeld
9366f11dcb In generated C, only format printable characters as char literals 2014-08-07 08:12:15 -07:00
Max Brunsfeld
b155994491 Fix indentation in specs 2014-08-07 08:11:21 -07:00
Max Brunsfeld
01571da30d Handle more escaped characters in regexps 2014-08-03 21:57:21 -07:00
Max Brunsfeld
4720672cfb In lexer, stop reading input as soon as empty string is returned 2014-08-01 13:27:50 -07:00
Max Brunsfeld
03a5a97992 Move StringInput into its own file 2014-08-01 12:43:14 -07:00
Max Brunsfeld
41d26aaceb Fix segfault when document's input is set before its language 2014-08-01 12:34:49 -07:00
Max Brunsfeld
412cc93812 clang format 2014-07-31 13:11:39 -07:00
Max Brunsfeld
0d6d09cbd9 In generated parsers, export language as a function 2014-07-31 13:04:46 -07:00
Max Brunsfeld
909261d742 Remove unnecessary type name in parser.h 2014-07-31 12:31:38 -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
048a479b5f Fix missing initializer warning in gcc 2014-07-29 13:04:19 -07:00
Max Brunsfeld
f1eb9a92a3 Separate .gyp files for libs and tests 2014-07-25 12:55:00 -07:00
Max Brunsfeld
6a8addb84f Fix segfault when grammar consists of a single token 2014-07-23 18:26:10 -07:00
Max Brunsfeld
df3613d511 Make compiler and runtime libraries two separate targets 2014-07-22 13:11:07 -07:00
Max Brunsfeld
18e918b704 Fix lint errors in public compiler header 2014-07-22 09:03:33 -07:00