Commit graph

350 commits

Author SHA1 Message Date
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
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
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
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
6a8addb84f Fix segfault when grammar consists of a single token 2014-07-23 18:26:10 -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
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
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
4d14a65e22 In build_parse_table, switch recursion to explicit iteration 2014-07-13 18:06:37 -07:00
Max Brunsfeld
b217cd38fb Handle built-in symbols correctly in conflict manager 2014-07-13 17:59:57 -07:00
Max Brunsfeld
44c4bf5f5e Refactor add_ubiquitous_token_actions method 2014-07-11 13:21:44 -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
f4287c07d0 Fix ParseStateId / size_t confusion in parse table 2014-07-07 13:21:30 -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
67590eddc7 Fix stream operator for new parse action types 2014-07-03 08:15:36 -07:00
Max Brunsfeld
18ae326459 Fix lint errors 2014-07-02 09:01:38 -07:00
Max Brunsfeld
6424eea62a Refactor handling of ubiquitous tokens when building parse table 2014-07-01 21:43:26 -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
da7b50a2d1 Rename type ts_string_input_data -> TSStringInput 2014-06-28 19:29:44 -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