Replace NodeType enum with SymbolMetadata bitfield
This will allow storing other metadata about symbols, like if they only appear as ubiquitous tokens
This commit is contained in:
parent
53424699e4
commit
f08554e958
17 changed files with 541 additions and 512 deletions
|
|
@ -142,23 +142,25 @@ class CCodeGenerator {
|
|||
}
|
||||
|
||||
void add_symbol_node_types_list() {
|
||||
line("static const TSNodeType ts_node_types[SYMBOL_COUNT] = {");
|
||||
line("static const TSSymbolMetadata ts_symbol_metadata[SYMBOL_COUNT] = {");
|
||||
indent([&]() {
|
||||
for (const auto &symbol : parse_table.symbols) {
|
||||
line("[" + symbol_id(symbol) + "] = ");
|
||||
line("[" + symbol_id(symbol) + "] = {");
|
||||
|
||||
switch (symbol_type(symbol)) {
|
||||
case VariableTypeNamed:
|
||||
add("TSNodeTypeNamed,");
|
||||
add(".visible = true, .named = true");
|
||||
break;
|
||||
case VariableTypeAnonymous:
|
||||
add("TSNodeTypeAnonymous,");
|
||||
add(".visible = true, .named = false");
|
||||
break;
|
||||
case VariableTypeHidden:
|
||||
case VariableTypeAuxiliary:
|
||||
add("TSNodeTypeHidden,");
|
||||
add(".visible = false, .named = false");
|
||||
break;
|
||||
}
|
||||
|
||||
add("},");
|
||||
}
|
||||
});
|
||||
line("};");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue