clang-format everything

This commit is contained in:
Max Brunsfeld 2015-07-27 18:29:48 -07:00
parent 766e3bab2c
commit f9b057f3a9
44 changed files with 496 additions and 416 deletions

View file

@ -16,7 +16,7 @@ typedef std::shared_ptr<Rule> rule_ptr;
enum Associativity {
AssociativityLeft = 1,
AssociativityRight
AssociativityRight,
};
rule_ptr blank();
@ -68,7 +68,8 @@ class GrammarError {
std::string message;
};
std::pair<std::string, const GrammarError *> compile(const Grammar &, std::string);
std::pair<std::string, const GrammarError *> compile(const Grammar &,
std::string);
std::ostream &operator<<(std::ostream &stream, const Grammar &grammar);
std::ostream &operator<<(std::ostream &stream, const GrammarError *error);

View file

@ -73,19 +73,19 @@ struct TSLanguage {
* Lexer Macros
*/
#define START_LEXER() \
#define START_LEXER() \
const bool error_mode = (lex_state == ts_lex_state_error); \
lexer->start_fn(lexer, lex_state); \
int32_t lookahead; \
next_state: \
lexer->start_fn(lexer, lex_state); \
int32_t lookahead; \
next_state: \
lookahead = lexer->lookahead;
#define START_TOKEN() lexer->start_token_fn(lexer);
#define GO_TO_STATE(state_index) \
{ \
lex_state = state_index; \
goto next_state; \
#define GO_TO_STATE(state_index) \
{ \
lex_state = state_index; \
goto next_state; \
}
#define ADVANCE(state_index) \
@ -98,60 +98,63 @@ struct TSLanguage {
return lexer->accept_fn(lexer, symbol, ts_hidden_symbol_flags[symbol], \
ts_symbol_names[symbol]);
#define LEX_ERROR() \
if (error_mode) { \
if (lex_state == ts_lex_state_error) \
ADVANCE(ts_lex_state_error) \
else \
GO_TO_STATE(ts_lex_state_error) \
} else { \
ACCEPT_TOKEN(ts_builtin_sym_error) \
#define LEX_ERROR() \
if (error_mode) { \
if (lex_state == ts_lex_state_error) \
ADVANCE(ts_lex_state_error) \
else \
GO_TO_STATE(ts_lex_state_error) \
} else { \
ACCEPT_TOKEN(ts_builtin_sym_error) \
}
/*
* Parse Table Macros
*/
#define ACTIONS(...) \
(TSParseAction[]) {__VA_ARGS__, {.type = 0}}
#define ACTIONS(...) \
(TSParseAction[]) { \
__VA_ARGS__, { .type = 0 } \
}
#define SHIFT(to_state_value) \
{ \
.type = TSParseActionTypeShift, .data = { .to_state = to_state_value } \
#define SHIFT(to_state_value) \
{ \
.type = TSParseActionTypeShift, .data = {.to_state = to_state_value } \
}
#define SHIFT_EXTRA() \
{ .type = TSParseActionTypeShiftExtra }
#define REDUCE_EXTRA(symbol_val) \
{ \
.type = TSParseActionTypeReduceExtra, .data = { .symbol = symbol_val } \
#define REDUCE_EXTRA(symbol_val) \
{ \
.type = TSParseActionTypeReduceExtra, .data = {.symbol = symbol_val } \
}
#define REDUCE(symbol_val, child_count_val) \
{ \
.type = TSParseActionTypeReduce, \
.data = { .symbol = symbol_val, .child_count = child_count_val } \
#define REDUCE(symbol_val, child_count_val) \
{ \
.type = TSParseActionTypeReduce, \
.data = {.symbol = symbol_val, .child_count = child_count_val } \
}
#define REDUCE_FRAGILE(symbol_val, child_count_val) \
{ \
.type = TSParseActionTypeReduceFragile, \
.data = { .symbol = symbol_val, .child_count = child_count_val } \
#define REDUCE_FRAGILE(symbol_val, child_count_val) \
{ \
.type = TSParseActionTypeReduceFragile, \
.data = {.symbol = symbol_val, .child_count = child_count_val } \
}
#define ACCEPT_INPUT() \
{ .type = TSParseActionTypeAccept }
#define EXPORT_LANGUAGE(language_name) \
static TSLanguage language = { .symbol_count = SYMBOL_COUNT, \
.hidden_symbol_flags = ts_hidden_symbol_flags, \
.parse_table = \
(const TSParseAction **)ts_parse_actions, \
.lex_states = ts_lex_states, \
.symbol_names = ts_symbol_names, \
.lex_fn = ts_lex, }; \
\
#define EXPORT_LANGUAGE(language_name) \
static TSLanguage language = { \
.symbol_count = SYMBOL_COUNT, \
.hidden_symbol_flags = ts_hidden_symbol_flags, \
.parse_table = (const TSParseAction **)ts_parse_actions, \
.lex_states = ts_lex_states, \
.symbol_names = ts_symbol_names, \
.lex_fn = ts_lex, \
}; \
\
const TSLanguage *language_name() { return &language; }
#ifdef __cplusplus

View file

@ -22,7 +22,7 @@ typedef struct {
typedef enum {
TSDebugTypeParse,
TSDebugTypeLex
TSDebugTypeLex,
} TSDebugType;
typedef struct {