summaryrefslogtreecommitdiffstats
path: root/eo_tokenizer.h
blob: adcba08b1bbb243dcd50319c98a4d366d228b593 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef __EO_TOKENIZER_H__
#define __EO_TOKENIZER_H__

#include <Eina.h>

extern int _eo_tokenizer_log_dom;
#undef EINA_LOG_DOMAIN_DEFAULT
#define EINA_LOG_DOMAIN_DEFAULT _eo_tokenizer_log_dom

#ifdef CRITICAL
#undef CRITICAL
#endif
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eo_tokenizer_log_dom, __VA_ARGS__)

#ifdef ERR
#undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(_eo_tokenizer_log_dom, __VA_ARGS__)

#ifdef WRN
#undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(_eo_tokenizer_log_dom, __VA_ARGS__)

#ifdef INF
#undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(_eo_tokenizer_log_dom, __VA_ARGS__)

#ifdef DBG
#undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eo_tokenizer_log_dom, __VA_ARGS__)

/* RET */

typedef struct _eo_ret {
    char *type;
    char *comment;
} Eo_Ret;

/* PARAMS */

typedef enum _param_way {
    IN,
    OUT,
    INOUT
} Param_Way;

typedef struct _eo_param {
    Param_Way way;
    char *type;
    char *name;
    char *comment;
} Eo_Param;

/* PROPERTIES */

typedef enum _property_type {
    SETTER,
    GETTER
} Property_Type;

typedef struct _eo_property {
    Property_Type type;
    Eo_Ret ret;
    char *name;
    char *comment;
    Eina_List *params;
} Eo_Property;

/* METHODS */

typedef struct _eo_method {
    Eo_Ret ret;
    char *name;
    char *comment;
    Eina_List *params;
} Eo_Method;

/* CLASSES */

typedef struct _eo_class {
    char *name;
    char *comment;
    Eina_List *inherits;
    Eina_List *properties;
    Eina_List *methods;
} Eo_Class;

/* TOKENIZER */

#define BUFSIZE 256

typedef struct _eo_tokenizer {
     /* ragel vars */
     int cs;        /* current machine state */
     int act;       /* last pattern matched */
     char *ts;      /* current token match start */
     char *te;      /* current token match end */
     char *p;       /* data start */
     char *pe;      /* data end */
     char *eof;     /* eof = (EOF ? pe : NULL) */
     /* int stack[10]; /1* state stack used by fret fcall ... *1/ */
     /* int top;       /1* stack pointer *1/ */

     const char *source;
     int current_line;
     int current_nesting;
     int max_nesting;
     int token_start_line;
     char buf[BUFSIZE];

     Eina_List *classes;
} Eo_Tokenizer;

Eo_Tokenizer* eo_tokenizer_get();

Eina_Bool eo_tokenizer_walk(Eo_Tokenizer *toknz, const char *source);

void eo_tokenizer_dump(Eo_Tokenizer *toknz);

void eo_tokenizer_free(Eo_Tokenizer *toknz);

#endif /* __EO_TOKENIZER_H__ */