libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
loc.c
Go to the documentation of this file.
1// Copyright (C) 2023 Ethan Uppal. All rights reserved.
2
3#include <stdio.h>
4#include "loc.h"
5
7 printf("%s:%zu:%zu (pos %zu)", self->filename, self->line, self->col,
8 self->pos);
9})
10
11struct ps_loc PS_LOC_NONE(void) {
12 struct ps_loc loc;
13 loc.filename = NULL;
14 loc.line = 0;
15 loc.col = 0;
16 loc.pos = 0;
17 return loc;
18}
19
20bool ps_is_loc_none(const struct ps_loc* loc) {
21 return loc->filename == NULL && loc->line == 0 && loc->col == 0
22 && loc->pos == 0;
23}
static void usize struct ps_loc loc
Definition lexer.h:76
bool ps_is_loc_none(const struct ps_loc *loc)
Whether the token location is an not actual location.
Definition loc.c:20
File location structure.
struct ps_loc PS_LOC_NONE(void)
Represents the absence token location.
#define PS_PRINT_IMPL(T,...)
Definition print.h:10
Represents a token location.
Definition loc.h:16
STR filename
The file where the token is from.
Definition loc.h:17
usize pos
The token's position in the text.
Definition loc.h:20
usize line
The line number where the token is found.
Definition loc.h:18
usize col
The column number where the token starts.
Definition loc.h:19