Skip to content
Myr

c_lexer_test.c

This file

Path

tests/c_lexer_test.c

50 lines · 3.6 KiB · C

Last changed by

Not known.

History of this file

Take it

1#define STB_C_LEX_C_DECIMAL_INTS    Y   //  "0|[1-9][0-9]*"                        CLEX_intlit2#define STB_C_LEX_C_HEX_INTS        Y   //  "0x[0-9a-fA-F]+"                       CLEX_intlit3#define STB_C_LEX_C_OCTAL_INTS      Y   //  "[0-7]+"                               CLEX_intlit4#define STB_C_LEX_C_DECIMAL_FLOATS  Y   //  "[0-9]*(.[0-9]*([eE][-+]?[0-9]+)?)     CLEX_floatlit5#define STB_C_LEX_C99_HEX_FLOATS    Y   //  "0x{hex}+(.{hex}*)?[pP][-+]?{hex}+     CLEX_floatlit6#define STB_C_LEX_C_IDENTIFIERS     Y   //  "[_a-zA-Z][_a-zA-Z0-9]*"               CLEX_id7#define STB_C_LEX_C_DQ_STRINGS      Y   //  double-quote-delimited strings with escapes  CLEX_dqstring8#define STB_C_LEX_C_SQ_STRINGS      Y   //  single-quote-delimited strings with escapes  CLEX_ssstring9#define STB_C_LEX_C_CHARS           Y   //  single-quote-delimited character with escape CLEX_charlits10#define STB_C_LEX_C_COMMENTS        Y   //  "/* comment */"11#define STB_C_LEX_CPP_COMMENTS      Y   //  "// comment to end of line\n"12#define STB_C_LEX_C_COMPARISONS     Y   //  "==" CLEX_eq  "!=" CLEX_noteq   "<=" CLEX_lesseq  ">=" CLEX_greatereq13#define STB_C_LEX_C_LOGICAL         Y   //  "&&"  CLEX_andand   "||"  CLEX_oror14#define STB_C_LEX_C_SHIFTS          Y   //  "<<"  CLEX_shl      ">>"  CLEX_shr15#define STB_C_LEX_C_INCREMENTS      Y   //  "++"  CLEX_plusplus "--"  CLEX_minusminus16#define STB_C_LEX_C_ARROW           Y   //  "->"  CLEX_arrow17#define STB_C_LEX_EQUAL_ARROW       Y   //  "=>"  CLEX_eqarrow18#define STB_C_LEX_C_BITWISEEQ       Y   //  "&="  CLEX_andeq    "|="  CLEX_oreq     "^="  CLEX_xoreq19#define STB_C_LEX_C_ARITHEQ         Y   //  "+="  CLEX_pluseq   "-="  CLEX_minuseq20                                        //  "*="  CLEX_muleq    "/="  CLEX_diveq    "%=" CLEX_modeq21                                        //  if both STB_C_LEX_SHIFTS & STB_C_LEX_ARITHEQ:22                                        //                      "<<=" CLEX_shleq    ">>=" CLEX_shreq2324#define STB_C_LEX_PARSE_SUFFIXES    Y   // letters after numbers are parsed as part of those numbers, and must be in suffix list below25#define STB_C_LEX_DECIMAL_SUFFIXES  "uUlL"  // decimal integer suffixes e.g. "uUlL" -- these are returned as-is in string storage26#define STB_C_LEX_HEX_SUFFIXES      "lL"  // e.g. "uUlL"27#define STB_C_LEX_OCTAL_SUFFIXES    "lL"  // e.g. "uUlL"28#define STB_C_LEX_FLOAT_SUFFIXES    "uulL"  //2930#define STB_C_LEX_0_IS_EOF             N  // if Y, ends parsing at '\0'; if N, returns '\0' as token31#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==N32#define STB_C_LEX_MULTILINE_DSTRINGS   Y  // allow newlines in double-quoted strings33#define STB_C_LEX_MULTILINE_SSTRINGS   Y  // allow newlines in single-quoted strings34#define STB_C_LEX_USE_STDLIB           N  // use strtod,strtol for parsing #s; otherwise inaccurate hack35#define STB_C_LEX_DOLLAR_IDENTIFIER    Y  // allow $ as an identifier character36#define STB_C_LEX_FLOAT_NO_DECIMAL     Y  // allow floats that have no decimal point if they have an exponent3738#define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES  Y   // if Y, all CLEX_ token names are defined, even if never returned39                                              // leaving it as N should help you catch config bugs4041#define STB_C_LEX_DISCARD_PREPROCESSOR    Y   // discard C-preprocessor directives (e.g. after prepocess42                                              // still have #line, #pragma, etc)4344#define STB_C_LEXER_DEFINITIONS         // This line prevents the header file from replacing your definitions45464748#define STB_C_LEXER_IMPLEMENTATION49#define STB_C_LEXER_SELF_TEST50#include "../stb_c_lexer.h"