File: scanner.h

package info (click to toggle)
viewcvs 0.9.2%2Bcvs.1.0.dev.2004.07.28-4.1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 1,452 kB
  • ctags: 1,355
  • sloc: python: 10,100; cpp: 840; ansic: 763; yacc: 526; sh: 163; makefile: 115
file content (42 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download | duplicates (3)
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
#ifndef SCANNER_H
#define SCANNER_H


#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


/* constants and errors returned by the scanner */
enum
{
    SCANNER_EOF = -1,           /* returned by get_char_t and
                                   scanner_get_token to symbolize EOF */

    E_TOO_MANY_INDENTS = -100,  /* too many indents */
    E_DEDENT_MISMATCH,          /* no matching indent */
    E_BAD_CONTINUATION,         /* character occurred after \ */
    E_BAD_NUMBER,               /* parse error in a number */
    E_UNKNOWN_TOKEN,            /* dunno what we found */
    E_UNTERM_STRING             /* unterminated string constant */
};

typedef int (*get_char_t)(void *user_ctx);

void *scanner_begin(get_char_t getfunc, void *user_ctx);

int scanner_get_token(void *ctx);

void scanner_identifier(void *ctx, const char **ident, int *len);
void scanner_token_range(void *ctx, int *start, int *end);
void scanner_token_linecol(void *ctx,
                           int *sline, int *scol, int *eline, int *ecol);

void scanner_end(void *ctx);


#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* SCANNER_H */