moberg_config_parser_module.h 1.11 KB
Newer Older
Anders Blomdell's avatar
Anders Blomdell committed
1
2
3
4
#ifndef __MOBERG_CONFIG_PARSER_MODULE_H__
#define __MOBERG_CONFIG_PARSER_MODULE_H__

#include <stdio.h>
Anders Blomdell's avatar
Anders Blomdell committed
5
#include <moberg_config_parser.h>
Anders Blomdell's avatar
Anders Blomdell committed
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
45
46
47
48
49
50
51
52
53
54
55
56

struct moberg_config_parser_token;

enum moberg_config_parser_token_kind {
  tok_none,
  tok_EOF,
  tok_LPAREN,
  tok_RPAREN,
  tok_LBRACE,
  tok_RBRACE,
  tok_LBRACKET,
  tok_RBRACKET,
  tok_EQUAL,
  tok_COMMA,
  tok_COLON,
  tok_SEMICOLON,
  tok_INTEGER,
  tok_IDENT,
  tok_STRING,
};

struct moberg_config_parser_ident {
  int length;
  const char *value;
};

struct moberg_config_parser_token {
  enum moberg_config_parser_token_kind kind;
  union {
    struct moberg_config_parser_ident ident;
    struct moberg_config_parser_ident string;
    struct moberg_config_parser_integer {
      int value;
    } integer;
  } u;
};

int moberg_config_parser_acceptsym(
  struct moberg_config_parser_context *c,
  enum moberg_config_parser_token_kind kind,
  struct moberg_config_parser_token *token);

int moberg_config_parser_acceptkeyword(
  struct moberg_config_parser_context *c,
  const char *keyword);

void moberg_config_parser_failed(
  struct moberg_config_parser_context *c,
  FILE *f);

#endif