Skip to content

Commit 21a4303

Browse files
committed
Move booleans on the parser to the end so they are more compact
1 parent 0c57060 commit 21a4303

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

include/yarp/parser.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ typedef struct yp_scope {
291291
// it's considering.
292292
struct yp_parser {
293293
yp_lex_state_t lex_state; // the current state of the lexer
294-
bool command_start; // whether or not we're at the beginning of a command
295294
int enclosure_nesting; // tracks the current nesting of (), [], and {}
296295

297296
// Used to temporarily track the nesting of enclosures to determine if a {
@@ -338,17 +337,11 @@ struct yp_parser {
338337
yp_scope_t *current_scope; // the current local scope
339338

340339
yp_context_node_t *current_context; // the current parsing context
341-
bool recovering; // whether or not we're currently recovering from a syntax error
342340

343341
// The encoding functions for the current file is attached to the parser as
344342
// it's parsing so that it can change with a magic comment.
345343
yp_encoding_t encoding;
346344

347-
// Whether or not the encoding has been changed by a magic comment. We use
348-
// this to provide a fast path for the lexer instead of going through the
349-
// function pointer.
350-
bool encoding_changed;
351-
352345
// When the encoding that is being used to parse the source is changed by
353346
// YARP, we provide the ability here to call out to a user-defined function.
354347
yp_encoding_changed_callback_t encoding_changed_callback;
@@ -367,13 +360,6 @@ struct yp_parser {
367360
// be called whenever a new token is lexed by the parser.
368361
yp_lex_callback_t *lex_callback;
369362

370-
// This flag indicates that we are currently parsing a pattern matching
371-
// expression and impacts that calculation of newlines.
372-
bool pattern_matching_newlines;
373-
374-
// This flag indicates that we are currently parsing a keyword argument.
375-
bool in_keyword_arg;
376-
377363
// This is the path of the file being parsed
378364
// We use the filepath when constructing SourceFileNodes
379365
yp_string_t filepath_string;
@@ -390,6 +376,24 @@ struct yp_parser {
390376
// communicate this information. So we store it here and pass it through
391377
// when we find tokens that we need it for.
392378
yp_node_flags_t integer_base;
379+
380+
// Whether or not we're at the beginning of a command
381+
unsigned int command_start : 1;
382+
383+
// Whether or not we're currently recovering from a syntax error
384+
unsigned int recovering : 1;
385+
386+
// Whether or not the encoding has been changed by a magic comment. We use
387+
// this to provide a fast path for the lexer instead of going through the
388+
// function pointer.
389+
unsigned int encoding_changed : 1;
390+
391+
// This flag indicates that we are currently parsing a pattern matching
392+
// expression and impacts that calculation of newlines.
393+
unsigned int pattern_matching_newlines : 1;
394+
395+
// This flag indicates that we are currently parsing a keyword argument.
396+
unsigned int in_keyword_arg : 1;
393397
};
394398

395399
#endif // YARP_PARSER_H

0 commit comments

Comments
 (0)