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
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
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
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
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
41d26aaceb
Fix segfault when document's input is set before its language
2014-08-01 12:34:49 -07:00
Max Brunsfeld
0d6d09cbd9
In generated parsers, export language as a function
2014-07-31 13:04:46 -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
6a8addb84f
Fix segfault when grammar consists of a single token
2014-07-23 18:26:10 -07:00
Max Brunsfeld
af5a118000
Add ts_node_child_count function
2014-07-20 17:57:20 -07:00
Max Brunsfeld
466daeaf99
Add function for retrieving a leaf node by position
2014-07-18 18:52:08 -07:00
Max Brunsfeld
1ecafb874e
Add functions to retrieve nodes' siblings and parents
2014-07-18 13:24:03 -07:00
Max Brunsfeld
0e11bf7271
Precompute trees' visible children
2014-07-18 13:08:14 -07:00
Max Brunsfeld
b3385f20c8
Hide TSTree, expose TSNode
2014-07-17 23:29:11 -07:00
Max Brunsfeld
02904085c2
Make separate helper scripts for testing compiler and runtime
2014-07-17 22:20:14 -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
6951acb13b
Fix error when grammar contains to error productions
2014-07-13 21:26:21 -07:00
Max Brunsfeld
7dfaba2954
Fix conflict manager spec
2014-07-13 18:10:32 -07:00
Max Brunsfeld
b217cd38fb
Handle built-in symbols correctly in conflict manager
2014-07-13 17:59:57 -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
1c7d2d2d03
Add for-in loops and math assignment operators to js grammar
2014-07-07 13:35:55 -07:00
Max Brunsfeld
77df7fe511
In lexer, always prefer the longest match
...
Only use rules' precedence to decide between two tokens
that match the same string
2014-07-03 08:57:35 -07:00
Max Brunsfeld
c85841364e
Add throw statements to js grammar
2014-07-03 08:20:43 -07:00
Max Brunsfeld
83a1b9439e
Fix handling of ubiquitous tokens used in grammar rules
2014-07-01 20:47:35 -07:00
Max Brunsfeld
0ec3faba3e
Rename type ts_lr_parser -> TSStateMachine
2014-06-28 19:22:16 -07:00
Max Brunsfeld
27f6eb725d
Rename type ts_parse_action -> TSParseAction
2014-06-28 19:06:37 -07:00
Max Brunsfeld
26f612a20d
Rename type ts_stack -> TSStack
2014-06-28 19:04:14 -07:00
Max Brunsfeld
9d4fcf75de
Rename type ts_lexer, ts_parser -> TSLexer, TSParser
2014-06-28 19:01:46 -07:00
Max Brunsfeld
ff13122419
Rename type ts_input -> TSInput
2014-06-28 18:56:04 -07:00
Max Brunsfeld
7e0d46002c
Rename type ts_state_id -> TSStateId
2014-06-28 18:51:06 -07:00
Max Brunsfeld
5f59de72a8
Rename type ts_tree -> TSTree
2014-06-28 18:48:07 -07:00
Max Brunsfeld
2795078633
Rename type ts_document -> TSDocument
2014-06-28 18:37:29 -07:00
Max Brunsfeld
3be648593e
merge_{sym,char}_transitions -> merge_{sym,char}_transition
2014-06-28 17:02:48 -07:00
Max Brunsfeld
9bad5dff3e
Avoid unnecessary std::map construction when merging transition sets
2014-06-26 13:42:42 -07:00
Max Brunsfeld
9686c57e90
Allow ubiquitous tokens to also be used in grammar rules
2014-06-26 08:52:42 -07:00
Max Brunsfeld
a9dff20658
Make grammars' separator characters configurable
2014-06-26 07:31:08 -07:00
Max Brunsfeld
7df35f9b8d
Make separate types for syntax and lexical grammars
...
This way, the separator characters can be added as a field to
lexical grammars only
2014-06-25 13:27:16 -07:00