Angband
parser.h
Go to the documentation of this file.
1 
25 #ifndef PARSER_H
26 #define PARSER_H
27 
28 #include "h-basic.h"
29 #include "z-bitflag.h"
30 #include "z-dice.h"
31 #include "z-rand.h"
32 
33 struct parser;
34 
36  #define PARSE_ERROR(a, b) PARSE_ERROR_##a,
37  #include "list-parser-errors.h"
38  #undef PARSE_ERROR
39 
41 };
42 
43 struct parser_state {
45  unsigned int line;
46  unsigned int col;
47  char *msg;
48 };
49 
50 extern struct parser *parser_new(void);
51 extern enum parser_error parser_parse(struct parser *p, const char *line);
52 extern void parser_destroy(struct parser *p);
53 extern void *parser_priv(struct parser *p);
54 extern void parser_setpriv(struct parser *p, void *v);
55 extern errr parser_reg(struct parser *p, const char *fmt,
56  enum parser_error (*func)(struct parser *p));
57 extern enum parser_error ignored(struct parser *p);
58 extern bool parser_hasval(struct parser *p, const char *name);
59 extern const char *parser_getsym(struct parser *p, const char *name);
60 extern const char *parser_getstr(struct parser *p, const char *name);
61 extern int parser_getint(struct parser *p, const char *name);
62 extern unsigned int parser_getuint(struct parser *p, const char *name);
63 extern struct random parser_getrand(struct parser *p, const char *name);
64 extern wchar_t parser_getchar(struct parser *p, const char *name);
65 extern int parser_getstate(struct parser *p, struct parser_state *s);
66 extern void parser_setstate(struct parser *p, unsigned int col, const char *msg);
67 
68 #endif /* !PARSER_H */
unsigned int line
Definition: parser.h:45
struct random parser_getrand(struct parser *p, const char *name)
Returns the random value named name.
Definition: parser.c:566
Definition: parser.h:106
Low-level bit vector manipulation.
bool parser_hasval(struct parser *p, const char *name)
Returns whether the parser has a value named name.
Definition: parser.c:507
parser_error
Definition: parser.h:35
errr parser_reg(struct parser *p, const char *fmt, enum parser_error(*func)(struct parser *p))
Registers a parser hook.
Definition: parser.c:468
int parser_getint(struct parser *p, const char *name)
Returns the integer named name.
Definition: parser.c:539
int parser_getstate(struct parser *p, struct parser_state *s)
Fills the provided struct with the parser's state, if any.
Definition: parser.c:585
unsigned int parser_getuint(struct parser *p, const char *name)
Returns the unsigned integer named name.
Definition: parser.c:548
int errr
ANSI C headers.
Definition: h-basic.h:164
const char * name
Definition: generate.c:60
char * msg
Definition: parser.h:47
The lowest level header.
const char * msg
Definition: mon-msg.c:77
const char * parser_getsym(struct parser *p, const char *name)
Returns the symbol named name.
Definition: parser.c:530
Represent more complex dice than random_value.
const char ** p[]
Definition: name.c:40
void * parser_priv(struct parser *p)
Gets parser's private data.
Definition: parser.c:336
Parse errors and descriptions.
struct parser * parser_new(void)
Allocates a new parser.
Definition: parser.c:88
Definition: parser.h:43
void parser_destroy(struct parser *p)
Destroys a parser.
Definition: parser.c:384
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
const char * parser_getstr(struct parser *p, const char *name)
Returns the string named name.
Definition: parser.c:557
unsigned int col
Definition: parser.h:46
void parser_setpriv(struct parser *p, void *v)
Sets parser's private data.
Definition: parser.c:345
enum parser_error parser_parse(struct parser *p, const char *line)
Parses the provided line.
Definition: parser.c:205
enum parser_error ignored(struct parser *p)
A placeholder parse hook indicating a value is ignored.
Definition: parser.c:498
Definition: parser.c:74
Intialize random names
Definition: init.c:658
void parser_setstate(struct parser *p, unsigned int col, const char *msg)
Sets the parser's detailed error description and field number.
Definition: parser.c:596
wchar_t parser_getchar(struct parser *p, const char *name)
Returns the character named name.
Definition: parser.c:575
enum parser_error error
Definition: parser.h:44
A Random Number Generator for Angband.