4coder/4cpp_lexer_fsms.h

117 lines
1.6 KiB
C
Raw Normal View History

2016-03-24 01:05:28 +00:00
/*
2016-08-29 01:03:26 +00:00
* FSMs for 4cpp lexer
2016-03-24 01:05:28 +00:00
*
* 23.03.2016 (dd.mm.yyyy)
2016-08-29 01:03:26 +00:00
*
2016-03-24 01:05:28 +00:00
*/
// TOP
2016-08-29 01:03:26 +00:00
#if !defined(FCPP_LEXER_FSMS_H)
#define FCPP_LEXER_FSMS_H
2016-03-31 04:05:47 +00:00
2016-03-24 01:05:28 +00:00
enum Lex_State{
LS_default,
LS_identifier,
LS_pound,
LS_pp,
LS_char,
2016-03-24 14:01:53 +00:00
LS_char_multiline,
2016-03-24 01:05:28 +00:00
LS_char_slashed,
LS_string,
2016-03-24 14:01:53 +00:00
LS_string_multiline,
2016-03-24 01:05:28 +00:00
LS_string_slashed,
LS_number,
LS_number0,
LS_float,
LS_crazy_float0,
LS_crazy_float1,
LS_hex,
LS_comment_pre,
LS_comment,
LS_comment_slashed,
LS_comment_block,
LS_comment_block_ending,
LS_dot,
LS_ellipsis,
LS_less,
LS_less_less,
LS_more,
LS_more_more,
LS_minus,
LS_arrow,
LS_and,
LS_or,
LS_plus,
LS_colon,
LS_star,
LS_modulo,
LS_caret,
LS_eq,
LS_bang,
LS_error_message,
//
LS_count
};
enum Lex_Int_State{
LSINT_default,
LSINT_u,
LSINT_l,
LSINT_L,
LSINT_ul,
LSINT_uL,
LSINT_ll,
2016-03-26 08:06:41 +00:00
LSINT_extra,
//
LSINT_count
2016-03-24 01:05:28 +00:00
};
enum Lex_INC_State{
LSINC_default,
LSINC_quotes,
LSINC_pointy,
LSINC_junk,
};
enum Lex_PP_State{
LSPP_default,
LSPP_include,
LSPP_macro_identifier,
LSPP_identifier,
LSPP_body_if,
LSPP_body,
LSPP_number,
LSPP_error,
LSPP_junk,
//
LSPP_count
};
struct Whitespace_FSM{
2016-08-29 01:03:26 +00:00
uint8_t pp_state;
uint8_t white_done;
2016-03-24 01:05:28 +00:00
};
struct Lex_FSM{
2016-08-29 01:03:26 +00:00
uint8_t state;
2016-03-31 04:05:47 +00:00
union{
2016-08-29 01:03:26 +00:00
uint8_t int_state;
uint8_t directive_state;
uint8_t sub_machine;
2016-03-31 04:05:47 +00:00
};
2016-08-29 01:03:26 +00:00
uint8_t emit_token;
uint8_t multi_line;
2016-03-24 01:05:28 +00:00
};
inline Lex_FSM
zero_lex_fsm(){
Lex_FSM fsm = {0};
return(fsm);
}
2016-03-24 01:05:28 +00:00
2016-08-29 01:03:26 +00:00
#endif
2016-03-24 01:05:28 +00:00
// BOTTOM