Commit graph

115 commits

Author SHA1 Message Date
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
Max Brunsfeld
292b753914 Move lr_parser into its own header file 2014-05-09 14:43:43 -07:00
Max Brunsfeld
ccc1b41f2a Make separate header files for stack and lexer 2014-05-09 13:32:12 -07:00
Max Brunsfeld
e4be585c43 Handle ubiquitous tokens at the beginning of programs
As a final step before returning the finished parse tree, check if
there are still multiple nodes on the stack. If so, make the inner
nodes children of the top node.
2014-05-09 12:46:36 -07:00
Max Brunsfeld
3f374c6547 Tidy up 2014-05-08 13:27:48 -07:00
Max Brunsfeld
34137be12d Represent state ids as unsigned shorts
This fixes some signedness conversion warnings
2014-05-08 13:23:46 -07:00
Max Brunsfeld
0a21eee3f0 Remove magic number from generated symbols enums
The symbol numbers 0 and 1 are reserved for 'error' and 'eof',
so the grammar's start symbol is always 2.
2014-05-08 13:14:45 -07:00