libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
lexer.h File Reference

Interface for the lexer. More...

#include "def.h"
#include "loc.h"
#include "util/io.h"
#include <stdbool.h>
#include "token.h"
#include "util/dynarrs.h"

Go to the source code of this file.

Data Structures

struct  ps_lexer_state
 Represents lexer state for a single file. More...
 

Macros

#define PS_LEXER_MAX_ERRORS   5
 The lexer will stop in its tracks after it encounters this many errors.
 
#define ps_lexer_next_are(next, n)   _ps_lexer_next_are(next, n)
 Whether the next n characters in the lexer stream, starting from the current character, match next.
 
#define ps_lexer_next_are_lit(next)    _ps_lexer_next_are(next, sizeof(next) - 1)
 Whether the next characters in the lexer stream, starting from the current character, match next, which is provided as a string literal.
 

Functions

struct ps_token_arr * ps_lex (const struct ps_file_ctx *file_ctx)
 Lexes the given source code into tokens.
 

Variables

static void usize length
 
static void usize struct ps_loc loc
 

Detailed Description

Interface for the lexer.

Author
Ethan Uppal

Definition in file lexer.h.

Macro Definition Documentation

◆ PS_LEXER_MAX_ERRORS

#define PS_LEXER_MAX_ERRORS   5

The lexer will stop in its tracks after it encounters this many errors.

Definition at line 22 of file lexer.h.

◆ ps_lexer_next_are

#define ps_lexer_next_are (   next,
 
)    _ps_lexer_next_are(next, n)

Whether the next n characters in the lexer stream, starting from the current character, match next.

Definition at line 51 of file lexer.h.

◆ ps_lexer_next_are_lit

#define ps_lexer_next_are_lit (   next)     _ps_lexer_next_are(next, sizeof(next) - 1)

Whether the next characters in the lexer stream, starting from the current character, match next, which is provided as a string literal.

Definition at line 56 of file lexer.h.

Function Documentation

◆ ps_lex()

struct ps_token_arr * ps_lex ( const struct ps_file_ctx file_ctx)

Lexes the given source code into tokens.

Parameters
file_ctxThe file contents and filename.

Definition at line 559 of file lexer.c.

Variable Documentation

◆ length

static void usize length

Definition at line 71 of file lexer.h.

◆ loc

void usize struct ps_loc loc

Definition at line 76 of file lexer.h.