libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
Macros | Functions
tstream_short.h File Reference
#include "def.h"
#include "tstream.h"

Go to the source code of this file.

Macros

#define eof()   ps_tstream_is_eof(ts)
 
#define adv()   ps_tstream_advance(ts)
 
#define match(type, ctx)
 Tries to match the next token with the given token type, opening a block for if no match succeeded.
 
#define bindmatch(val, type, ctx)
 Tries to match the next token with the given token type and assign the token to the given variable, opening a block for if no match succeeded.
 
#define bindmatch_any(val, types, ctx)
 
#define tcur()   ps_tstream_current(ts)
 
#define unwind()   ps_tstream_advance_n(ts, -1)
 

Functions

void ps_tstream_eof_error (struct ps_tstream *ts, int code, STR ctx, STR fix)
 Reports an end-of-file error with the given context ctx, using the last token in ts for location.
 

Macro Definition Documentation

◆ adv

#define adv ( )    ps_tstream_advance(ts)

Definition at line 21 of file tstream_short.h.

◆ bindmatch

#define bindmatch (   val,
  type,
  ctx 
)
Value:
auto_t val = ps_tstream_match(ts, type, ctx); \
if (val) { \
}
#define auto_t
Definition def.h:53
struct ps_token * ps_tstream_match(struct ps_tstream *ts, enum ps_token_type type, STR ctx)
Attempts to match the next token with the given token type.
Definition tstream.c:36

Tries to match the next token with the given token type and assign the token to the given variable, opening a block for if no match succeeded.

Definition at line 35 of file tstream_short.h.

◆ bindmatch_any

#define bindmatch_any (   val,
  types,
  ctx 
)
Value:
auto_t val = ps_tstream_match_any(ts, types, lengthof(types), ctx); \
if (val) { \
}
#define lengthof(array)
Definition def.h:55
struct ps_token * ps_tstream_match_any(struct ps_tstream *ts, enum ps_token_type types[], usize count, STR ctx)
Attempts to match the next token with one of the given token types.
Definition tstream.c:69
See also
bindmatch

Definition at line 43 of file tstream_short.h.

◆ eof

#define eof ( )    ps_tstream_is_eof(ts)

Definition at line 19 of file tstream_short.h.

◆ match

#define match (   type,
  ctx 
)
Value:
if (ps_tstream_match(ts, type, ctx)) { \
}

Tries to match the next token with the given token type, opening a block for if no match succeeded.

Definition at line 27 of file tstream_short.h.

◆ tcur

#define tcur ( )    ps_tstream_current(ts)

Definition at line 48 of file tstream_short.h.

◆ unwind

#define unwind ( )    ps_tstream_advance_n(ts, -1)

Definition at line 50 of file tstream_short.h.

Function Documentation

◆ ps_tstream_eof_error()

void ps_tstream_eof_error ( struct ps_tstream ts,
int  code,
STR  ctx,
STR  fix 
)

Reports an end-of-file error with the given context ctx, using the last token in ts for location.

Precondition
The token stream ts must be non-empty.
Parameters
codeThe error code for the error. Supply -1 for a default error code.

Definition at line 99 of file tstream.c.