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.
This commit is contained in:
parent
9302080aa6
commit
1e79ed794b
17 changed files with 78 additions and 39 deletions
|
|
@ -1,10 +1,10 @@
|
|||
#include "tree_sitter/parser.h"
|
||||
|
||||
#define STATE_COUNT 32
|
||||
#define SYMBOL_COUNT 18
|
||||
#define SYMBOL_COUNT 19
|
||||
|
||||
enum {
|
||||
ts_sym_expression = ts_start_sym,
|
||||
ts_sym_expression = ts_builtin_sym_start,
|
||||
ts_sym_sum,
|
||||
ts_sym_difference,
|
||||
ts_sym_product,
|
||||
|
|
@ -23,6 +23,7 @@ enum {
|
|||
};
|
||||
|
||||
SYMBOL_NAMES = {
|
||||
[ts_builtin_sym_document] = "DOCUMENT",
|
||||
[ts_sym_expression] = "expression",
|
||||
[ts_sym_sum] = "sum",
|
||||
[ts_sym_difference] = "difference",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include "tree_sitter/parser.h"
|
||||
|
||||
#define STATE_COUNT 372
|
||||
#define SYMBOL_COUNT 87
|
||||
#define SYMBOL_COUNT 88
|
||||
|
||||
enum {
|
||||
ts_sym_program = ts_start_sym,
|
||||
ts_sym_program = ts_builtin_sym_start,
|
||||
ts_sym_package_directive,
|
||||
ts_sym_imports_block,
|
||||
ts_sym_package_import,
|
||||
|
|
@ -92,6 +92,7 @@ enum {
|
|||
};
|
||||
|
||||
SYMBOL_NAMES = {
|
||||
[ts_builtin_sym_document] = "DOCUMENT",
|
||||
[ts_sym_program] = "program",
|
||||
[ts_sym_package_directive] = "package_directive",
|
||||
[ts_sym_imports_block] = "imports_block",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include "tree_sitter/parser.h"
|
||||
|
||||
#define STATE_COUNT 2212
|
||||
#define SYMBOL_COUNT 109
|
||||
#define SYMBOL_COUNT 110
|
||||
|
||||
enum {
|
||||
ts_sym_program = ts_start_sym,
|
||||
ts_sym_program = ts_builtin_sym_start,
|
||||
ts_sym_statement,
|
||||
ts_sym_statement_block,
|
||||
ts_sym_for_statement,
|
||||
|
|
@ -114,6 +114,7 @@ enum {
|
|||
};
|
||||
|
||||
SYMBOL_NAMES = {
|
||||
[ts_builtin_sym_document] = "DOCUMENT",
|
||||
[ts_sym_program] = "program",
|
||||
[ts_sym_statement] = "statement",
|
||||
[ts_sym_statement_block] = "statement_block",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include "tree_sitter/parser.h"
|
||||
|
||||
#define STATE_COUNT 60
|
||||
#define SYMBOL_COUNT 18
|
||||
#define SYMBOL_COUNT 19
|
||||
|
||||
enum {
|
||||
ts_sym_value = ts_start_sym,
|
||||
ts_sym_value = ts_builtin_sym_start,
|
||||
ts_sym_object,
|
||||
ts_sym_array,
|
||||
ts_sym_string,
|
||||
|
|
@ -23,6 +23,7 @@ enum {
|
|||
};
|
||||
|
||||
SYMBOL_NAMES = {
|
||||
[ts_builtin_sym_document] = "DOCUMENT",
|
||||
[ts_sym_value] = "value",
|
||||
[ts_sym_object] = "object",
|
||||
[ts_sym_array] = "array",
|
||||
|
|
@ -319,6 +320,7 @@ LEX_FN() {
|
|||
ADVANCE(27);
|
||||
LEX_ERROR();
|
||||
case ts_lex_state_error:
|
||||
START_TOKEN();
|
||||
if (lookahead == 0)
|
||||
ADVANCE(25);
|
||||
if (('\t' <= lookahead && lookahead <= '\n') ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue