2014-06-18 03:25:07 -07:00
|
|
|
#ifndef __EO_LEXER_H__
|
|
|
|
#define __EO_LEXER_H__
|
|
|
|
|
|
|
|
#include <setjmp.h>
|
2014-02-11 05:42:59 -08:00
|
|
|
|
|
|
|
#include <Eina.h>
|
2014-02-17 04:05:52 -08:00
|
|
|
#include <Eolian.h>
|
2014-02-11 05:42:59 -08:00
|
|
|
#include "eo_definitions.h"
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
#define START_CUSTOM 257
|
|
|
|
|
|
|
|
enum Tokens
|
|
|
|
{
|
2014-06-20 02:45:55 -07:00
|
|
|
TOK_COMMENT = START_CUSTOM, TOK_EOF, TOK_VALUE
|
2014-06-18 03:25:07 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define KEYWORDS KW(class), KW(const), KW(private), KW(protected), \
|
|
|
|
KW(return), KW(signed), KW(struct), KW(unsigned), KW(virtual), \
|
|
|
|
KW(abstract), KW(constructor), KW(constructors), KW(data), \
|
|
|
|
KW(destructor), KW(eo_prefix), KW(events), KW(get), KW(implements), \
|
|
|
|
KW(interface), KW(keys), KW(legacy), KW(legacy_prefix), KW(methods), \
|
|
|
|
KW(mixin), KW(params), KW(properties), KW(set), KW(type), KW(values), \
|
|
|
|
KWAT(in), KWAT(inout), KWAT(nonull), KWAT(out), KWAT(own), KWAT(warn_unused)
|
|
|
|
|
|
|
|
#define KW(x) KW_##x
|
|
|
|
#define KWAT(x) KW_at_##x
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
enum Keywords
|
|
|
|
{
|
|
|
|
KW_UNKNOWN = 0,
|
|
|
|
KEYWORDS,
|
|
|
|
NUM_KEYWORDS
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef KW
|
|
|
|
#undef KWAT
|
|
|
|
|
|
|
|
typedef struct _Eo_Token
|
|
|
|
{
|
|
|
|
int token;
|
|
|
|
const char *value;
|
|
|
|
int kw;
|
|
|
|
} Eo_Token;
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
typedef struct _Eo_Lexer
|
2014-02-11 05:42:59 -08:00
|
|
|
{
|
2014-06-18 03:25:07 -07:00
|
|
|
int current;
|
|
|
|
int line_number;
|
|
|
|
Eo_Token t, lookahead;
|
|
|
|
Eina_Strbuf *buff;
|
|
|
|
Eina_File *handle;
|
|
|
|
const char *source;
|
|
|
|
const char *stream;
|
2014-06-20 02:45:55 -07:00
|
|
|
const char *stream_end;
|
2014-06-18 03:25:07 -07:00
|
|
|
jmp_buf err_jmp;
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-23 10:44:11 -07:00
|
|
|
Eina_List *classes;
|
|
|
|
Eina_List *typedefs;
|
2014-06-18 03:25:07 -07:00
|
|
|
Eo_Lexer_Temps tmp;
|
2014-06-18 02:08:43 -07:00
|
|
|
} Eo_Lexer;
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-20 07:31:45 -07:00
|
|
|
int eo_lexer_init (void);
|
|
|
|
int eo_lexer_shutdown (void);
|
|
|
|
Eo_Lexer *eo_lexer_new (const char *source);
|
|
|
|
void eo_lexer_free (Eo_Lexer *ls);
|
|
|
|
int eo_lexer_get_balanced (Eo_Lexer *ls, char beg, char end);
|
|
|
|
int eo_lexer_get_until (Eo_Lexer *ls, char end);
|
|
|
|
int eo_lexer_get (Eo_Lexer *ls);
|
|
|
|
int eo_lexer_get_ident (Eo_Lexer *ls, const char *chars);
|
|
|
|
int eo_lexer_lookahead (Eo_Lexer *ls);
|
|
|
|
int eo_lexer_lookahead_ident(Eo_Lexer *ls, const char *chars);
|
|
|
|
void eo_lexer_lex_error (Eo_Lexer *ls, const char *msg, int token);
|
|
|
|
void eo_lexer_syntax_error (Eo_Lexer *ls, const char *msg);
|
|
|
|
void eo_lexer_token_to_str (int token, char *buf);
|
|
|
|
const char *eo_lexer_keyword_str_get(int kw);
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
extern int _eo_lexer_log_dom;
|
|
|
|
#ifdef CRITICAL
|
|
|
|
#undef CRITICAL
|
|
|
|
#endif
|
|
|
|
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eo_lexer_log_dom, __VA_ARGS__)
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
#ifdef ERR
|
|
|
|
#undef ERR
|
|
|
|
#endif
|
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(_eo_lexer_log_dom, __VA_ARGS__)
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
#ifdef WRN
|
|
|
|
#undef WRN
|
|
|
|
#endif
|
|
|
|
#define WRN(...) EINA_LOG_DOM_WARN(_eo_lexer_log_dom, __VA_ARGS__)
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
#define INF_ENABLED EINA_FALSE
|
|
|
|
#ifdef INF
|
|
|
|
#undef INF
|
|
|
|
#endif
|
|
|
|
#define INF(...) if (INF_ENABLED) EINA_LOG_DOM_INFO(_eo_lexer_log_dom, __VA_ARGS__)
|
2014-02-11 05:42:59 -08:00
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
#define DBG_ENABLED EINA_FALSE
|
|
|
|
#ifdef DBG
|
|
|
|
#undef DBG
|
|
|
|
#endif
|
|
|
|
#define DBG(...) if (DBG_ENABLED) EINA_LOG_DOM_DBG(_eo_lexer_log_dom, __VA_ARGS__)
|
2014-02-11 05:42:59 -08:00
|
|
|
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
#endif /* __EO_LEXER_H__ */
|