Fix initializer list deduction warnings in specs
This commit is contained in:
parent
0193be166b
commit
226ffd6b5b
4 changed files with 57 additions and 23 deletions
|
|
@ -93,14 +93,14 @@ struct TSLanguage {
|
|||
|
||||
#define LEX_FN() static TSTree *ts_lex(TSLexer *lexer, TSStateId lex_state)
|
||||
|
||||
#define DEBUG_LEX(...) \
|
||||
if (lexer->debug) { \
|
||||
#define DEBUG_LEX(...) \
|
||||
if (lexer->debug) { \
|
||||
fprintf(stderr, "LEX " __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
fprintf(stderr, "\n"); \
|
||||
}
|
||||
|
||||
#define START_LEXER() \
|
||||
DEBUG_LEX("START %d", lex_state); \
|
||||
DEBUG_LEX("START %d", lex_state); \
|
||||
char lookahead; \
|
||||
next_state: \
|
||||
lookahead = ts_lexer_lookahead_char(lexer); \
|
||||
|
|
@ -112,7 +112,7 @@ struct TSLanguage {
|
|||
{ \
|
||||
DEBUG_LEX("ADVANCE %d", state_index); \
|
||||
if (ts_lexer_is_done(lexer)) { \
|
||||
DEBUG_LEX("END"); \
|
||||
DEBUG_LEX("END"); \
|
||||
return NULL; \
|
||||
} \
|
||||
ts_lexer_advance(lexer); \
|
||||
|
|
|
|||
|
|
@ -19,13 +19,21 @@ describe("computing closures of item sets", []() {
|
|||
}, {});
|
||||
|
||||
it("adds items at the beginnings of referenced rules", [&]() {
|
||||
ParseItemSet item_set = item_set_closure(ParseItem(Symbol(0), grammar.rule(Symbol(0)), 0),
|
||||
{ Symbol(10, SymbolOptionToken) },
|
||||
grammar);
|
||||
ParseItemSet item_set = item_set_closure(
|
||||
ParseItem(Symbol(0), grammar.rule(Symbol(0)), 0),
|
||||
set<Symbol>({ Symbol(10, SymbolOptionToken) }),
|
||||
grammar
|
||||
);
|
||||
|
||||
AssertThat(item_set, Equals(ParseItemSet({
|
||||
{ ParseItem(Symbol(1), grammar.rule(Symbol(1)), 0), { Symbol(11, SymbolOptionToken) } },
|
||||
{ ParseItem(Symbol(0), grammar.rule(Symbol(0)), 0), { Symbol(10, SymbolOptionToken) } },
|
||||
{
|
||||
ParseItem(Symbol(1), grammar.rule(Symbol(1)), 0),
|
||||
set<Symbol>({ Symbol(11, SymbolOptionToken) }),
|
||||
},
|
||||
{
|
||||
ParseItem(Symbol(0), grammar.rule(Symbol(0)), 0),
|
||||
set<Symbol>({ Symbol(10, SymbolOptionToken) }),
|
||||
},
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,16 +13,29 @@ describe("lexical item set transitions", []() {
|
|||
it("merges the transitions by computing the union of the two item sets", [&]() {
|
||||
LexItemSet set1({
|
||||
LexItem(Symbol(1), CharacterSet().include('a', 'f').copy()),
|
||||
LexItem(Symbol(2), CharacterSet().include('e', 'x').copy()) });
|
||||
LexItem(Symbol(2), CharacterSet().include('e', 'x').copy())
|
||||
});
|
||||
|
||||
AssertThat(char_transitions(set1), Equals(map<CharacterSet, LexItemSet>({
|
||||
{ CharacterSet().include('a', 'd'), LexItemSet({
|
||||
LexItem(Symbol(1), blank()) }) },
|
||||
{ CharacterSet().include('e', 'f'), LexItemSet({
|
||||
LexItem(Symbol(1), blank()),
|
||||
LexItem(Symbol(2), blank()) }) },
|
||||
{ CharacterSet().include('g', 'x'), LexItemSet({
|
||||
LexItem(Symbol(2), blank()) }) },
|
||||
{
|
||||
CharacterSet().include('a', 'd'),
|
||||
LexItemSet({
|
||||
LexItem(Symbol(1), blank()),
|
||||
})
|
||||
},
|
||||
{
|
||||
CharacterSet().include('e', 'f'),
|
||||
LexItemSet({
|
||||
LexItem(Symbol(1), blank()),
|
||||
LexItem(Symbol(2), blank()),
|
||||
})
|
||||
},
|
||||
{
|
||||
CharacterSet().include('g', 'x'),
|
||||
LexItemSet({
|
||||
LexItem(Symbol(2), blank()),
|
||||
})
|
||||
},
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
|
@ -36,14 +49,26 @@ describe("syntactic item set transitions", [&]() {
|
|||
|
||||
it("computes the closure of the new item sets", [&]() {
|
||||
ParseItemSet set1({
|
||||
{ ParseItem(Symbol(0), seq({ i_token(22), i_sym(1) }), 3), { Symbol(23, SymbolOptionToken) } },
|
||||
{
|
||||
ParseItem(Symbol(0), seq({ i_token(22), i_sym(1) }), 3),
|
||||
set<Symbol>({ Symbol(23, SymbolOptionToken) })
|
||||
},
|
||||
});
|
||||
|
||||
AssertThat(sym_transitions(set1, grammar), Equals(map<Symbol, ParseItemSet>({
|
||||
{ Symbol(22, SymbolOptionToken), ParseItemSet({
|
||||
{ ParseItem(Symbol(0), i_sym(1), 4), { Symbol(23, SymbolOptionToken) } },
|
||||
{ ParseItem(Symbol(1), i_token(21), 0), { Symbol(23, SymbolOptionToken) } },
|
||||
}) },
|
||||
{
|
||||
Symbol(22, SymbolOptionToken),
|
||||
ParseItemSet({
|
||||
{
|
||||
ParseItem(Symbol(0), i_sym(1), 4),
|
||||
set<Symbol>({ Symbol(23, SymbolOptionToken) }),
|
||||
},
|
||||
{
|
||||
ParseItem(Symbol(1), i_token(21), 0),
|
||||
set<Symbol>({ Symbol(23, SymbolOptionToken) })
|
||||
},
|
||||
})
|
||||
},
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ TSTree *ts_tree_make_node(TSSymbol symbol, size_t child_count,
|
|||
.size = size,
|
||||
.offset = offset,
|
||||
.options = options };
|
||||
|
||||
result->children = children;
|
||||
result->child_count = child_count;
|
||||
result->visible_child_count = visible_child_count;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue