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
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
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
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
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
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
18e918b704
Fix lint errors in public compiler header
2014-07-22 09:03:33 -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
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
b3385f20c8
Hide TSTree, expose TSNode
2014-07-17 23:29:11 -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
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
83a1b9439e
Fix handling of ubiquitous tokens used in grammar rules
2014-07-01 20:47:35 -07:00
Max Brunsfeld
59cc65c2e3
Rename parse action types
2014-06-29 00:20:16 -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
c8797bfa27
Rename type ts_input_edit -> TSInputEdit
2014-06-28 18:56:47 -07:00
Max Brunsfeld
ff13122419
Rename type ts_input -> TSInput
2014-06-28 18:56:04 -07:00
Max Brunsfeld
d7449bf5ea
Rename type ts_symbol -> TSSymbol
2014-06-28 18:53:32 -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
9686c57e90
Allow ubiquitous tokens to also be used in grammar rules
2014-06-26 08:52:42 -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
Max Brunsfeld
3cd031af38
Add keypattern rule helper
...
This way, pattern rules (e.g. golang's comment) can be easily given the
same precedence as keyword rules.
2014-06-11 12:40:49 -07:00
Max Brunsfeld
155a57d3ab
Prevent infinite loop on certain lex errors
2014-06-11 11:49:06 -07:00
Max Brunsfeld
11acc7d087
Fix missing initializer warnings
2014-06-09 21:47:57 -07:00
Max Brunsfeld
21c259df9c
Clean up lint errors
2014-06-09 21:14:38 -07:00
Max Brunsfeld
54a555168d
Add accessor methods on Grammar
2014-06-09 21:05:25 -07:00
Max Brunsfeld
12331d66f5
Fix memory leaks
2014-06-09 13:12:44 -07:00
Max Brunsfeld
652fa2f8a5
Fix stack spec on gcc
2014-06-04 18:24:54 -07:00
Max Brunsfeld
9a4889176e
Move lr_parser implementation into a separate .c file
2014-06-04 13:34:37 -07:00
Max Brunsfeld
63cde3967c
Add unit test for stack
...
- Also, fix bug where trees pushed onto the stack were not retained
2014-06-03 13:19:49 -07:00
Max Brunsfeld
baec9f2c9a
Move computation of tree size/offset into tree constructor
2014-06-02 13:32:36 -07:00
Max Brunsfeld
868a09b0b0
Remove infinite loop on certain lex errors
2014-06-01 23:23:24 -07:00
Max Brunsfeld
e93e254518
In lexer, prefer tokens to skipped separator characters
...
This was causing newlines in go and javascript to be parsed as
meaningless separator characters instead of statement terminators
2014-05-30 13:29:54 -07:00
Max Brunsfeld
2988cc5aa2
Show offending lookahead chars when pretty-printing trees w/ errors
2014-05-26 21:50:01 -07:00
Max Brunsfeld
649f200831
Expand regex/string rules as part of grammar preparation
...
This makes it possible to report errors in regex parsing
2014-05-19 20:54:59 -07:00
Max Brunsfeld
3e0debf814
Fix compile error on gcc
2014-05-09 15:37:30 -07:00