efl/src/lib/eolian/eo_lexer.h

146 lines
3.6 KiB
C
Raw Normal View History

#ifndef __EO_LEXER_H__
#define __EO_LEXER_H__
#include <setjmp.h>
#include <Eina.h>
#include <Eolian.h>
#include "eo_definitions.h"
#define START_CUSTOM 257
enum Tokens
{
TOK_COMMENT = START_CUSTOM, TOK_EOF, TOK_VALUE
};
#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(func), KW(get), \
KW(implements), KW(interface), KW(keys), KW(legacy), KW(legacy_prefix), \
2014-06-30 10:10:29 -07:00
KW(methods), KW(mixin), KW(own), KW(params), KW(properties), KW(set), \
KW(type), KW(values), KWAT(in), KWAT(inout), KWAT(nonull), KWAT(out), \
KWAT(warn_unused), \
\
KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
KW(long), KW(ulong), KW(llong), KW(ullong), \
\
KW(int8), KW(uint8), KW(int16), KW(uint16), KW(int32), KW(uint32), \
KW(int64), KW(uint64), KW(int128), KW(uint128), \
\
KW(size), KW(ssize), KW(intptr), KW(uintptr), KW(ptrdiff), \
\
2014-07-14 09:02:58 -07:00
KW(time), \
\
KW(float), KW(double), KW(ldouble), \
\
KW(bool), \
\
KW(void), \
\
KW(true), KW(false), KW(null)
#define KW(x) KW_##x
#define KWAT(x) KW_at_##x
enum Keywords
{
KW_UNKNOWN = 0,
KEYWORDS
};
#undef KW
#undef KWAT
typedef struct _Eo_Token
{
int token;
const char *value;
int kw;
} Eo_Token;
enum Nodes
{
NODE_CLASS = 0,
NODE_TYPEDEF,
NODE_STRUCT
};
typedef struct _Eo_Node
{
unsigned char type;
union {
2014-06-27 02:55:54 -07:00
void *def;
Eo_Class_Def *def_class;
Eolian_Typedef *def_typedef;
2014-07-10 06:44:17 -07:00
Eolian_Type *def_struct;
};
} Eo_Node;
typedef struct _Eo_Lexer
{
int current;
2014-07-02 16:14:28 -07:00
int column, icolumn;
int line_number;
Eo_Token t, lookahead;
Eina_Strbuf *buff;
Eina_File *handle;
const char *source;
const char *stream;
const char *stream_end;
2014-07-02 16:30:39 -07:00
const char *stream_line;
jmp_buf err_jmp;
Eina_List *nodes;
Eo_Lexer_Temps tmp;
2014-06-18 02:08:43 -07:00
} Eo_Lexer;
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);
Eina_Bool eo_lexer_is_type_keyword(int kw);
const char *eo_lexer_get_c_type (int kw);
extern int _eo_lexer_log_dom;
#ifdef CRITICAL
#undef CRITICAL
#endif
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eo_lexer_log_dom, __VA_ARGS__)
#ifdef ERR
#undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(_eo_lexer_log_dom, __VA_ARGS__)
#ifdef WRN
#undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(_eo_lexer_log_dom, __VA_ARGS__)
#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__)
#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__)
#endif /* __EO_LEXER_H__ */