feat: rename root with file

This commit is contained in:
Ika 2019-08-20 15:01:47 +08:00
parent a3812033af
commit a0cd384b98
6 changed files with 97 additions and 97 deletions

View file

@ -4,7 +4,7 @@ VALID - empty file
--------------------------------------------------------------------------------
(root)
(file)
================================================================================
INVALID - key/value pair - multiline string for keys are not allowed
@ -26,7 +26,7 @@ key
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (ERROR) (boolean)
)
@ -45,7 +45,7 @@ invalid_both = 1 .0 e 2
--------------------------------------------------------------------------------
(root
(file
(ERROR
(dotted_key
(key) (ERROR) (key)
@ -62,7 +62,7 @@ invalid2 = 1979-05-27 T 07:32:00 Z
--------------------------------------------------------------------------------
(root
(file
(ERROR
(key) (ERROR) (local_time) (local_time)
)
@ -77,7 +77,7 @@ invalid2 = 1979-05-27 T 07:32:00
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (ERROR) (local_time)
)
@ -106,7 +106,7 @@ key
--------------------------------------------------------------------------------
(root
(file
(table
(key) (ERROR)
)
@ -125,7 +125,7 @@ key = {
--------------------------------------------------------------------------------
(root
(file
(pair
(key)
(inline_table
@ -158,7 +158,7 @@ key
--------------------------------------------------------------------------------
(root
(file
(ERROR
(key) (key)
)
@ -174,7 +174,7 @@ VALID - table - empty content separated by comments
--------------------------------------------------------------------------------
(root
(file
(table
(key)
)
@ -191,7 +191,7 @@ VALID - array of tables - empty content separated by comments
--------------------------------------------------------------------------------
(root
(file
(table_array
(key)
)
@ -212,7 +212,7 @@ b = 2
--------------------------------------------------------------------------------
(root
(file
(table
(key)
)
@ -239,7 +239,7 @@ b = 2
--------------------------------------------------------------------------------
(root
(file
(table_array
(key)
)

View file

@ -7,7 +7,7 @@ key = "value" # This is a comment at the end of a line
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(key) (string) (comment)
@ -22,7 +22,7 @@ key = "value"
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (string)
)
@ -36,7 +36,7 @@ key = # INVALID
--------------------------------------------------------------------------------
(root
(file
(ERROR
(key) (comment)
)
@ -53,7 +53,7 @@ bare-key = "value"
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (string)
)
@ -80,7 +80,7 @@ VALID - keys - quoted keys
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (string)
)
@ -108,7 +108,7 @@ INVALID - keys - empty bare key
--------------------------------------------------------------------------------
(root
(file
(pair
(key
(MISSING _bare_key)
@ -135,7 +135,7 @@ site."google.com" = true
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (string)
)
@ -169,7 +169,7 @@ name = "Pradyun"
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(key) (string)
@ -188,7 +188,7 @@ a.d = 2
--------------------------------------------------------------------------------
(root
(file
(pair
(dotted_key
(dotted_key
@ -216,7 +216,7 @@ a.b.c = 2
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(dotted_key
@ -243,7 +243,7 @@ str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
--------------------------------------------------------------------------------
(root
(file
(pair
(key)
(string
@ -262,7 +262,7 @@ Violets are blue"""
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (string)
)
@ -290,7 +290,7 @@ str3 = """\
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(key) (string)
@ -321,7 +321,7 @@ regex = '<\i\c*\s*>'
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(key) (string)
@ -351,7 +351,7 @@ trimmed in raw strings.
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (string)
)
@ -371,7 +371,7 @@ int4 = -17
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (integer)
)
@ -396,7 +396,7 @@ int7 = 1_2_3_4_5 # VALID but discouraged
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (integer)
)
@ -426,7 +426,7 @@ bin1 = 0b11010110
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(key) (integer)
@ -469,7 +469,7 @@ flt7 = 6.626e-34
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(key) (float)
@ -504,7 +504,7 @@ flt8 = 9_224_617.445_991_228_313
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (float)
)
@ -526,7 +526,7 @@ sf6 = -nan # valid, actual encoding is implementation specific
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(key) (float) (comment)
@ -558,7 +558,7 @@ bool2 = false
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (boolean)
)
@ -577,7 +577,7 @@ odt3 = 1979-05-27T00:32:00.999999-07:00
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (offset_date_time)
)
@ -597,7 +597,7 @@ odt4 = 1979-05-27 07:32:00Z
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (offset_date_time)
)
@ -612,7 +612,7 @@ ldt2 = 1979-05-27T00:32:00.999999
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (local_date_time)
)
@ -629,7 +629,7 @@ ld1 = 1979-05-27
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (local_date)
)
@ -644,7 +644,7 @@ lt2 = 00:32:00.999999
--------------------------------------------------------------------------------
(root
(file
(pair
(key) (local_time)
)
@ -667,7 +667,7 @@ arr6 = [ 1, 2.0 ] # INVALID
--------------------------------------------------------------------------------
(root
(file
(pair
(key)
(array
@ -732,7 +732,7 @@ arr8 = [
--------------------------------------------------------------------------------
(root
(file
(pair
(key)
(array
@ -755,7 +755,7 @@ VALID - table - header
--------------------------------------------------------------------------------
(root
(file
(table
(key)
)
@ -775,7 +775,7 @@ key2 = 456
--------------------------------------------------------------------------------
(root
(file
(table
(key)
)
@ -805,7 +805,7 @@ type.name = "pug"
--------------------------------------------------------------------------------
(root
(file
(table
(dotted_key
(key) (key)
@ -830,7 +830,7 @@ VALID - table- header with whitespaces
--------------------------------------------------------------------------------
(root
(file
(table
(dotted_key
(dotted_key
@ -880,7 +880,7 @@ VALID - table - directly defined nested header key
--------------------------------------------------------------------------------
(root
(file
(comment)
(comment)
(comment)
@ -912,7 +912,7 @@ c = 2
--------------------------------------------------------------------------------
(root
(file
(comment)
(table
(key)
@ -942,7 +942,7 @@ c = 2
--------------------------------------------------------------------------------
(root
(file
(comment)
(table
(key)
@ -970,7 +970,7 @@ animal = { type.name = "pug" }
--------------------------------------------------------------------------------
(root
(file
(pair
(key)
(inline_table
@ -1023,7 +1023,7 @@ color = "gray"
--------------------------------------------------------------------------------
(root
(file
(table_array
(key)
)
@ -1075,7 +1075,7 @@ VALID - array of tables - nested arrays of tables
--------------------------------------------------------------------------------
(root
(file
(table_array
(key)
)
@ -1136,7 +1136,7 @@ fruit = []
--------------------------------------------------------------------------------
(root
(file
(comment)
(pair
(key) (array)
@ -1163,7 +1163,7 @@ VALID - array of tables - append to table (semantically INVALID)
--------------------------------------------------------------------------------
(root
(file
(comment)
(table_array
(key)

View file

@ -28,7 +28,7 @@ module.exports = grammar({
extras: $ => [$.comment, /[ \t]/],
rules: {
root: $ => repeat(choice($.pair, $.table, $.table_array, $._newline)),
file: $ => repeat(choice($.pair, $.table, $.table_array, $._newline)),
comment: $ => /#.*/,
_newline: $ => newline,

2
src/grammar.json generated
View file

@ -1,7 +1,7 @@
{
"name": "toml",
"rules": {
"root": {
"file": {
"type": "REPEAT",
"content": {
"type": "CHOICE",

46
src/node-types.json generated
View file

@ -69,6 +69,29 @@
]
}
},
{
"type": "file",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "pair",
"named": true
},
{
"type": "table",
"named": true
},
{
"type": "table_array",
"named": true
}
]
}
},
{
"type": "float",
"named": true,
@ -183,29 +206,6 @@
]
}
},
{
"type": "root",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "pair",
"named": true
},
{
"type": "table",
"named": true
},
{
"type": "table_array",
"named": true
}
]
}
},
{
"type": "string",
"named": true,

38
src/parser.c generated
View file

@ -56,7 +56,7 @@ enum {
anon_sym_LBRACE = 39,
anon_sym_RBRACE = 40,
sym__line_ending_or_eof = 41,
sym_root = 42,
sym_file = 42,
sym_table = 43,
sym_table_array = 44,
sym_pair = 45,
@ -77,7 +77,7 @@ enum {
sym_local_date = 60,
sym_array = 61,
sym_inline_table = 62,
aux_sym_root_repeat1 = 63,
aux_sym_file_repeat1 = 63,
aux_sym__basic_string_repeat1 = 64,
aux_sym__multiline_basic_string_repeat1 = 65,
aux_sym__multiline_literal_string_repeat1 = 66,
@ -129,7 +129,7 @@ static const char *ts_symbol_names[] = {
[anon_sym_LBRACE] = "{",
[anon_sym_RBRACE] = "}",
[sym__line_ending_or_eof] = "_line_ending_or_eof",
[sym_root] = "root",
[sym_file] = "file",
[sym_table] = "table",
[sym_table_array] = "table_array",
[sym_pair] = "pair",
@ -150,7 +150,7 @@ static const char *ts_symbol_names[] = {
[sym_local_date] = "local_date",
[sym_array] = "array",
[sym_inline_table] = "inline_table",
[aux_sym_root_repeat1] = "root_repeat1",
[aux_sym_file_repeat1] = "file_repeat1",
[aux_sym__basic_string_repeat1] = "_basic_string_repeat1",
[aux_sym__multiline_basic_string_repeat1] = "_multiline_basic_string_repeat1",
[aux_sym__multiline_literal_string_repeat1] = "_multiline_literal_string_repeat1",
@ -328,7 +328,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = false,
.named = true,
},
[sym_root] = {
[sym_file] = {
.visible = true,
.named = true,
},
@ -412,7 +412,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = true,
.named = true,
},
[aux_sym_root_repeat1] = {
[aux_sym_file_repeat1] = {
.visible = false,
.named = false,
},
@ -1908,10 +1908,10 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = {
[sym_pair] = STATE(9),
[sym__inline_pair] = STATE(7),
[sym__basic_string] = STATE(4),
[sym_root] = STATE(8),
[sym_file] = STATE(8),
[sym_key] = STATE(10),
[sym_dotted_key] = STATE(10),
[aux_sym_root_repeat1] = STATE(9),
[aux_sym_file_repeat1] = STATE(9),
[sym__literal_string] = STATE(4),
[sym_table] = STATE(9),
[sym_table_array] = STATE(9),
@ -1977,7 +1977,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = {
[sym_pair] = STATE(18),
[sym__inline_pair] = STATE(7),
[sym__basic_string] = STATE(4),
[aux_sym_root_repeat1] = STATE(18),
[aux_sym_file_repeat1] = STATE(18),
[sym_dotted_key] = STATE(10),
[sym_key] = STATE(10),
[sym__literal_string] = STATE(4),
@ -2049,7 +2049,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = {
[sym_pair] = STATE(18),
[sym__inline_pair] = STATE(7),
[sym__basic_string] = STATE(4),
[aux_sym_root_repeat1] = STATE(18),
[aux_sym_file_repeat1] = STATE(18),
[sym_dotted_key] = STATE(10),
[sym_key] = STATE(10),
[sym__literal_string] = STATE(4),
@ -3648,7 +3648,7 @@ static TSParseActionEntry ts_parse_actions[] = {
[3] = {.count = 1, .reusable = true}, SHIFT_EXTRA(),
[5] = {.count = 1, .reusable = true}, SHIFT(2),
[7] = {.count = 1, .reusable = true}, SHIFT(3),
[9] = {.count = 1, .reusable = true}, REDUCE(sym_root, 0),
[9] = {.count = 1, .reusable = true}, REDUCE(sym_file, 0),
[11] = {.count = 1, .reusable = true}, SHIFT(9),
[13] = {.count = 1, .reusable = true}, SHIFT(4),
[15] = {.count = 1, .reusable = false}, SHIFT(5),
@ -3665,7 +3665,7 @@ static TSParseActionEntry ts_parse_actions[] = {
[37] = {.count = 1, .reusable = false}, SHIFT(16),
[39] = {.count = 1, .reusable = true}, SHIFT(17),
[41] = {.count = 1, .reusable = true}, ACCEPT_INPUT(),
[43] = {.count = 1, .reusable = true}, REDUCE(sym_root, 1),
[43] = {.count = 1, .reusable = true}, REDUCE(sym_file, 1),
[45] = {.count = 1, .reusable = true}, SHIFT(18),
[47] = {.count = 1, .reusable = true}, SHIFT(19),
[49] = {.count = 1, .reusable = true}, SHIFT(20),
@ -3680,13 +3680,13 @@ static TSParseActionEntry ts_parse_actions[] = {
[67] = {.count = 1, .reusable = true}, SHIFT(25),
[69] = {.count = 1, .reusable = true}, REDUCE(sym_pair, 2),
[71] = {.count = 1, .reusable = false}, REDUCE(sym_pair, 2),
[73] = {.count = 2, .reusable = true}, REDUCE(aux_sym_root_repeat1, 2), SHIFT_REPEAT(2),
[76] = {.count = 2, .reusable = true}, REDUCE(aux_sym_root_repeat1, 2), SHIFT_REPEAT(3),
[79] = {.count = 1, .reusable = true}, REDUCE(aux_sym_root_repeat1, 2),
[81] = {.count = 2, .reusable = true}, REDUCE(aux_sym_root_repeat1, 2), SHIFT_REPEAT(18),
[84] = {.count = 2, .reusable = true}, REDUCE(aux_sym_root_repeat1, 2), SHIFT_REPEAT(4),
[87] = {.count = 2, .reusable = false}, REDUCE(aux_sym_root_repeat1, 2), SHIFT_REPEAT(5),
[90] = {.count = 2, .reusable = true}, REDUCE(aux_sym_root_repeat1, 2), SHIFT_REPEAT(6),
[73] = {.count = 2, .reusable = true}, REDUCE(aux_sym_file_repeat1, 2), SHIFT_REPEAT(2),
[76] = {.count = 2, .reusable = true}, REDUCE(aux_sym_file_repeat1, 2), SHIFT_REPEAT(3),
[79] = {.count = 1, .reusable = true}, REDUCE(aux_sym_file_repeat1, 2),
[81] = {.count = 2, .reusable = true}, REDUCE(aux_sym_file_repeat1, 2), SHIFT_REPEAT(18),
[84] = {.count = 2, .reusable = true}, REDUCE(aux_sym_file_repeat1, 2), SHIFT_REPEAT(4),
[87] = {.count = 2, .reusable = false}, REDUCE(aux_sym_file_repeat1, 2), SHIFT_REPEAT(5),
[90] = {.count = 2, .reusable = true}, REDUCE(aux_sym_file_repeat1, 2), SHIFT_REPEAT(6),
[93] = {.count = 1, .reusable = false}, SHIFT(158),
[95] = {.count = 1, .reusable = true}, SHIFT(28),
[97] = {.count = 1, .reusable = true}, SHIFT(26),