test_c_lexer.c 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "stb_c_lexer.h"
  2. #define STB_C_LEX_C_DECIMAL_INTS Y // "0|[1-9][0-9]*" CLEX_intlit
  3. #define STB_C_LEX_C_HEX_INTS Y // "0x[0-9a-fA-F]+" CLEX_intlit
  4. #define STB_C_LEX_C_OCTAL_INTS Y // "[0-7]+" CLEX_intlit
  5. #define STB_C_LEX_C_DECIMAL_FLOATS Y // "[0-9]*(.[0-9]*([eE][-+]?[0-9]+)?) CLEX_floatlit
  6. #define STB_C_LEX_C99_HEX_FLOATS N // "0x{hex}+(.{hex}*)?[pP][-+]?{hex}+ CLEX_floatlit
  7. #define STB_C_LEX_C_IDENTIFIERS Y // "[_a-zA-Z][_a-zA-Z0-9]*" CLEX_id
  8. #define STB_C_LEX_C_DQ_STRINGS Y // double-quote-delimited strings with escapes CLEX_dqstring
  9. #define STB_C_LEX_C_SQ_STRINGS N // single-quote-delimited strings with escapes CLEX_ssstring
  10. #define STB_C_LEX_C_CHARS Y // single-quote-delimited character with escape CLEX_charlits
  11. #define STB_C_LEX_C_COMMENTS Y // "/* comment */"
  12. #define STB_C_LEX_CPP_COMMENTS Y // "// comment to end of line\n"
  13. #define STB_C_LEX_C_COMPARISONS Y // "==" CLEX_eq "!=" CLEX_noteq "<=" CLEX_lesseq ">=" CLEX_greatereq
  14. #define STB_C_LEX_C_LOGICAL Y // "&&" CLEX_andand "||" CLEX_oror
  15. #define STB_C_LEX_C_SHIFTS Y // "<<" CLEX_shl ">>" CLEX_shr
  16. #define STB_C_LEX_C_INCREMENTS Y // "++" CLEX_plusplus "--" CLEX_minusminus
  17. #define STB_C_LEX_C_ARROW Y // "->" CLEX_arrow
  18. #define STB_C_LEX_EQUAL_ARROW N // "=>" CLEX_eqarrow
  19. #define STB_C_LEX_C_BITWISEEQ Y // "&=" CLEX_andeq "|=" CLEX_oreq "^=" CLEX_xoreq
  20. #define STB_C_LEX_C_ARITHEQ Y // "+=" CLEX_pluseq "-=" CLEX_minuseq
  21. // "*=" CLEX_muleq "/=" CLEX_diveq "%=" CLEX_modeq
  22. // if both STB_C_LEX_SHIFTS & STB_C_LEX_ARITHEQ:
  23. // "<<=" CLEX_shleq ">>=" CLEX_shreq
  24. #define STB_C_LEX_PARSE_SUFFIXES N // letters after numbers are parsed as part of those numbers, and must be in suffix list below
  25. #define STB_C_LEX_DECIMAL_SUFFIXES "" // decimal integer suffixes e.g. "uUlL" -- these are returned as-is in string storage
  26. #define STB_C_LEX_HEX_SUFFIXES "" // e.g. "uUlL"
  27. #define STB_C_LEX_OCTAL_SUFFIXES "" // e.g. "uUlL"
  28. #define STB_C_LEX_FLOAT_SUFFIXES "" //
  29. #define STB_C_LEX_0_IS_EOF Y // if Y, ends parsing at '\0'; if N, returns '\0' as token
  30. #define STB_C_LEX_INTEGERS_AS_DOUBLES N // parses integers as doubles so they can be larger than 'int', but only if STB_C_LEX_STDLIB==N
  31. #define STB_C_LEX_MULTILINE_DSTRINGS N // allow newlines in double-quoted strings
  32. #define STB_C_LEX_MULTILINE_SSTRINGS N // allow newlines in single-quoted strings
  33. #define STB_C_LEX_USE_STDLIB Y // use strtod,strtol for parsing #s; otherwise inaccurate hack
  34. #define STB_C_LEX_DOLLAR_IDENTIFIER Y // allow $ as an identifier character
  35. #define STB_C_LEX_FLOAT_NO_DECIMAL Y // allow floats that have no decimal point if they have an exponent
  36. #define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES N // if Y, all CLEX_ token names are defined, even if never returned
  37. // leaving it as N should help you catch config bugs
  38. #define STB_C_LEX_DISCARD_PREPROCESSOR Y // discard C-preprocessor directives (e.g. after prepocess
  39. // still have #line, #pragma, etc)
  40. //#define STB_C_LEX_ISWHITE(str) ... // return length in bytes of whitespace characters if first char is whitespace
  41. #define STB_C_LEXER_DEFINITIONS // This line prevents the header file from replacing your definitions
  42. #include "stb_c_lexer.h"