-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.h
More file actions
44 lines (37 loc) · 1.09 KB
/
Copy pathparser.h
File metadata and controls
44 lines (37 loc) · 1.09 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
#include "unit.h"
#include <wchar.h>
struct parser_data {
/// Quantity in base units.
double quantity;
/// The base unit.
enum base base;
/// The source unit.
enum unit from;
/// The destination unit.
enum unit to;
};
enum parser_ret {
/// Parsing incomplete, more input needed.
PARSE_AGAIN,
/// Parsing complete.
PARSE_COMPLETE,
/// Parsing failed due to invalid arguments.
PARSE_INVALID_ARGUMENT,
/// Parsing failed due to incompatible compound unit.
PARSE_INVALID_COMPOUND,
/// Parsing failed due to invalid number.
PARSE_INVALID_NUMBER,
/// Parsing failed due to unknown unit.
PARSE_UNKNOWN_UNIT,
};
/// Parser object.
struct parser;
/// Constructor.
struct parser *parser_new(void);
/// Destructor.
void parser_delete(struct parser *);
/// Add @c word.
/// Accepts QUANTITY | QUANTITY UNIT | UNIT.
/// @param term Contains the failed term (number or unit) if this function returns an error.
/// @return enum parser_ret.
enum parser_ret parser_add(struct parser *, wchar_t *arg, wchar_t **term, struct parser_data *data);