|
@@ -42,6 +42,7 @@
|
|
//
|
|
//
|
|
// See end of file for license information.
|
|
// See end of file for license information.
|
|
|
|
|
|
|
|
+#ifdef STB_C_LEXER_IMPLEMENTATION
|
|
#ifndef STB_C_LEXER_DEFINITIONS
|
|
#ifndef STB_C_LEXER_DEFINITIONS
|
|
// to change the default parsing rules, copy the following lines
|
|
// to change the default parsing rules, copy the following lines
|
|
// into your C/C++ file *before* including this, and then replace
|
|
// into your C/C++ file *before* including this, and then replace
|
|
@@ -54,7 +55,6 @@
|
|
#error "Can only use stb_c_lexer in contexts where the preprocessor symbols 'Y' and 'N' are not defined"
|
|
#error "Can only use stb_c_lexer in contexts where the preprocessor symbols 'Y' and 'N' are not defined"
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-
|
|
|
|
#define STB_C_LEX_C_DECIMAL_INTS Y // "0|[1-9][0-9]*" CLEX_intlit
|
|
#define STB_C_LEX_C_DECIMAL_INTS Y // "0|[1-9][0-9]*" CLEX_intlit
|
|
#define STB_C_LEX_C_HEX_INTS Y // "0x[0-9a-fA-F]+" CLEX_intlit
|
|
#define STB_C_LEX_C_HEX_INTS Y // "0x[0-9a-fA-F]+" CLEX_intlit
|
|
#define STB_C_LEX_C_OCTAL_INTS Y // "[0-7]+" CLEX_intlit
|
|
#define STB_C_LEX_C_OCTAL_INTS Y // "[0-7]+" CLEX_intlit
|
|
@@ -102,7 +102,7 @@
|
|
|
|
|
|
#define STB_C_LEXER_DEFINITIONS // This line prevents the header file from replacing your definitions
|
|
#define STB_C_LEXER_DEFINITIONS // This line prevents the header file from replacing your definitions
|
|
// --END--
|
|
// --END--
|
|
-
|
|
|
|
|
|
+#endif
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifndef INCLUDE_STB_C_LEXER_H
|
|
#ifndef INCLUDE_STB_C_LEXER_H
|
|
@@ -172,78 +172,41 @@ extern void stb_c_lexer_get_location(const stb_lexer *lexer, const char *where,
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-// Hacky definitions so we can easily #if on them
|
|
|
|
-#define Y(x) 1
|
|
|
|
-#define N(x) 0
|
|
|
|
-
|
|
|
|
-// Config variable that influence which lexer tokens get declared need to go here
|
|
|
|
-#if STB_C_LEX_C_DECIMAL_INTS(x) || STB_C_LEX_C_HEX_INTS(x) || STB_C_LEX_DEFINE_ALL_TOKEN_NAMES(x)
|
|
|
|
-#define STB__clex_define_int
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
-#if (STB_C_LEX_C_ARITHEQ(x) && STB_C_LEX_C_SHIFTS(x)) || STB_C_LEX_DEFINE_ALL_TOKEN_NAMES(x)
|
|
|
|
-#define STB__clex_define_shifts
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
-// Now pick a definition of Y/N that's conducive to
|
|
|
|
-// defining the enum of token names.
|
|
|
|
-#if STB_C_LEX_DEFINE_ALL_TOKEN_NAMES(x) || defined(STB_C_LEXER_SELF_TEST)
|
|
|
|
- #undef N
|
|
|
|
- #define N(a) Y(a)
|
|
|
|
-#else
|
|
|
|
- #undef N
|
|
|
|
- #define N(a)
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
-#undef Y
|
|
|
|
-#define Y(a) a,
|
|
|
|
-
|
|
|
|
enum
|
|
enum
|
|
{
|
|
{
|
|
CLEX_eof = 256,
|
|
CLEX_eof = 256,
|
|
CLEX_parse_error,
|
|
CLEX_parse_error,
|
|
-
|
|
|
|
-#ifdef STB__clex_define_int
|
|
|
|
- CLEX_intlit,
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
- STB_C_LEX_C_DECIMAL_FLOATS( CLEX_floatlit )
|
|
|
|
- STB_C_LEX_C_IDENTIFIERS( CLEX_id )
|
|
|
|
- STB_C_LEX_C_DQ_STRINGS( CLEX_dqstring )
|
|
|
|
- STB_C_LEX_C_SQ_STRINGS( CLEX_sqstring )
|
|
|
|
- STB_C_LEX_C_CHARS( CLEX_charlit )
|
|
|
|
- STB_C_LEX_C_COMPARISONS( CLEX_eq )
|
|
|
|
- STB_C_LEX_C_COMPARISONS( CLEX_noteq )
|
|
|
|
- STB_C_LEX_C_COMPARISONS( CLEX_lesseq )
|
|
|
|
- STB_C_LEX_C_COMPARISONS( CLEX_greatereq )
|
|
|
|
- STB_C_LEX_C_LOGICAL( CLEX_andand )
|
|
|
|
- STB_C_LEX_C_LOGICAL( CLEX_oror )
|
|
|
|
- STB_C_LEX_C_SHIFTS( CLEX_shl )
|
|
|
|
- STB_C_LEX_C_SHIFTS( CLEX_shr )
|
|
|
|
- STB_C_LEX_C_INCREMENTS( CLEX_plusplus )
|
|
|
|
- STB_C_LEX_C_INCREMENTS( CLEX_minusminus )
|
|
|
|
- STB_C_LEX_C_ARITHEQ( CLEX_pluseq )
|
|
|
|
- STB_C_LEX_C_ARITHEQ( CLEX_minuseq )
|
|
|
|
- STB_C_LEX_C_ARITHEQ( CLEX_muleq )
|
|
|
|
- STB_C_LEX_C_ARITHEQ( CLEX_diveq )
|
|
|
|
- STB_C_LEX_C_ARITHEQ( CLEX_modeq )
|
|
|
|
- STB_C_LEX_C_BITWISEEQ( CLEX_andeq )
|
|
|
|
- STB_C_LEX_C_BITWISEEQ( CLEX_oreq )
|
|
|
|
- STB_C_LEX_C_BITWISEEQ( CLEX_xoreq )
|
|
|
|
- STB_C_LEX_C_ARROW( CLEX_arrow )
|
|
|
|
- STB_C_LEX_EQUAL_ARROW( CLEX_eqarrow )
|
|
|
|
-
|
|
|
|
-#ifdef STB__clex_define_shifts
|
|
|
|
|
|
+ CLEX_intlit ,
|
|
|
|
+ CLEX_floatlit ,
|
|
|
|
+ CLEX_id ,
|
|
|
|
+ CLEX_dqstring ,
|
|
|
|
+ CLEX_sqstring ,
|
|
|
|
+ CLEX_charlit ,
|
|
|
|
+ CLEX_eq ,
|
|
|
|
+ CLEX_noteq ,
|
|
|
|
+ CLEX_lesseq ,
|
|
|
|
+ CLEX_greatereq ,
|
|
|
|
+ CLEX_andand ,
|
|
|
|
+ CLEX_oror ,
|
|
|
|
+ CLEX_shl ,
|
|
|
|
+ CLEX_shr ,
|
|
|
|
+ CLEX_plusplus ,
|
|
|
|
+ CLEX_minusminus ,
|
|
|
|
+ CLEX_pluseq ,
|
|
|
|
+ CLEX_minuseq ,
|
|
|
|
+ CLEX_muleq ,
|
|
|
|
+ CLEX_diveq ,
|
|
|
|
+ CLEX_modeq ,
|
|
|
|
+ CLEX_andeq ,
|
|
|
|
+ CLEX_oreq ,
|
|
|
|
+ CLEX_xoreq ,
|
|
|
|
+ CLEX_arrow ,
|
|
|
|
+ CLEX_eqarrow ,
|
|
CLEX_shleq, CLEX_shreq,
|
|
CLEX_shleq, CLEX_shreq,
|
|
-#endif
|
|
|
|
|
|
|
|
CLEX_first_unused_token
|
|
CLEX_first_unused_token
|
|
|
|
|
|
};
|
|
};
|
|
-
|
|
|
|
-#undef Y
|
|
|
|
-#undef N
|
|
|
|
-
|
|
|
|
#endif // INCLUDE_STB_C_LEXER_H
|
|
#endif // INCLUDE_STB_C_LEXER_H
|
|
|
|
|
|
#ifdef STB_C_LEXER_IMPLEMENTATION
|
|
#ifdef STB_C_LEXER_IMPLEMENTATION
|