rename: h_seq_index_user -> h_seq_index -> h_seq_index_token
This commit is contained in:
parent
2d53a0f873
commit
2c90bd3ef5
2 changed files with 26 additions and 20 deletions
|
|
@ -43,34 +43,40 @@ const HParsedToken *h_act_flatten(const HParseResult *p);
|
|||
// Working with HParsedTokens
|
||||
//
|
||||
|
||||
// Standard short-hand for arena-allocating a variable in a semantic action.
|
||||
#define H_ALLOC(TYP) \
|
||||
((TYP *) h_arena_malloc(p->arena, sizeof(TYP)))
|
||||
|
||||
// Token constructors...
|
||||
|
||||
HParsedToken *h_make(HArena *arena, HTokenType type, void *value);
|
||||
HParsedToken *h_make_seq(HArena *arena);
|
||||
|
||||
#define H_ALLOC(TYP) \
|
||||
((TYP *) h_arena_malloc(p->arena, sizeof(TYP)))
|
||||
|
||||
#define H_MAKE(TYP, VAL) \
|
||||
h_make(p->arena, TT_ ## TYP, VAL)
|
||||
// Standard short-hand to make a user-type token.
|
||||
#define H_MAKE(TYP, VAL) h_make(p->arena, TT_ ## TYP, VAL)
|
||||
|
||||
// Sequences...
|
||||
|
||||
// Access a sequence element by index.
|
||||
HParsedToken *h_seq_index_token(const HParsedToken *p, size_t i);
|
||||
|
||||
// Access a user-type element of a sequence by index.
|
||||
#define H_SEQ_INDEX(TYP, SEQ, IDX) \
|
||||
((TYP *) h_seq_index(TT_ ## TYP, SEQ, IDX))
|
||||
|
||||
// Standard short-hand to access a user-type field on a sequence token.
|
||||
#define H_FIELD(TYP, IDX) H_SEQ_INDEX(TYP, p->ast, IDX)
|
||||
|
||||
// Append elements to a sequence.
|
||||
void h_seq_snoc(HParsedToken *xs, const HParsedToken *x); // append one
|
||||
void h_seq_append(HParsedToken *xs, const HParsedToken *ys); // append many
|
||||
|
||||
// Flatten nested sequences into one.
|
||||
const HParsedToken *h_seq_flatten(HArena *arena, const HParsedToken *p);
|
||||
|
||||
void h_seq_snoc(HParsedToken *xs, const HParsedToken *x);
|
||||
void h_seq_append(HParsedToken *xs, const HParsedToken *ys);
|
||||
|
||||
// Helpers for implementing H_SEQ_INDEX.
|
||||
void *h_seq_index(HTokenType type, const HParsedToken *p, size_t i); // XXX helper
|
||||
HParsedToken *h_carray_index(const HCountedArray *a, size_t i); // XXX -> internal
|
||||
HParsedToken *h_seq_index(const HParsedToken *p, size_t i);
|
||||
void *h_seq_index_user(HTokenType type, const HParsedToken *p, size_t i);
|
||||
|
||||
#define H_SEQ_INDEX(TYP, SEQ, IDX) \
|
||||
((TYP *) h_seq_index_user(TT_ ## TYP, SEQ, IDX))
|
||||
|
||||
#define H_FIELD(TYP, IDX) \
|
||||
H_SEQ_INDEX(TYP, p->ast, IDX)
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue