1 |
/* |
2 |
* Cisco 7200 (Predator) simulation platform. |
3 |
* Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) |
4 |
*/ |
5 |
|
6 |
#ifndef __PARSER_H__ |
7 |
#define __PARSER_H__ |
8 |
|
9 |
#include <sys/types.h> |
10 |
|
11 |
/* Parser Errors */ |
12 |
enum { |
13 |
PARSER_ERROR_NOMEM = 1, |
14 |
PARSER_ERROR_UNEXP_QUOTE, /* Unexpected quote in a word */ |
15 |
PARSER_ERROR_UNEXP_EOL, /* Unexpected end of line */ |
16 |
}; |
17 |
|
18 |
/* Token */ |
19 |
typedef struct parser_token parser_token_t; |
20 |
struct parser_token { |
21 |
char *value; |
22 |
struct parser_token *next; |
23 |
}; |
24 |
|
25 |
/* Get a description given an error code */ |
26 |
char *parser_strerror(int error); |
27 |
|
28 |
/* Free a token list */ |
29 |
void parser_free_tokens(parser_token_t *tok_list); |
30 |
|
31 |
/* Dump a token list */ |
32 |
void parser_dump_tokens(parser_token_t *tok_list); |
33 |
|
34 |
/* Map a token list to an array */ |
35 |
char **parser_map_array(parser_token_t *tok_list,int tok_count); |
36 |
|
37 |
/* Tokenize a string */ |
38 |
int parser_tokenize(char *str,struct parser_token **tokens,int *tok_count); |
39 |
|
40 |
#endif |