-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.h
More file actions
32 lines (23 loc) · 694 Bytes
/
parse.h
File metadata and controls
32 lines (23 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// (c) 2020 shdown
// This code is licensed under MIT license (see LICENSE.MIT for details)
#pragma once
#include "common.h"
#include "vm.h"
#include "position.h"
typedef struct {
Position pos;
// This might be '(size_t) -1', which means no size (nor position) is available.
size_t size;
// Allocated as if with 'malloc()'.
char *msg;
// Whether the error could, in theory, be recovered by appending something to the source.
bool need_more;
} ParseError;
typedef struct {
union {
Func *func;
ParseError error;
} as;
bool ok;
} ParseResult;
ParseResult parse(State *state, const char *source, size_t nsource, const char *origin);