Skip to content
Myr

test_c_lexer.c

This file

Path

tests/test_c_lexer.c

50 lines · 3.7 KiB · C

Last changed by

Merge branch 'master' into workingSean Barrettbefore adoption6e9f34d

History of this file

Take it

1#include "stb_c_lexer.h"23#define STB_C_LEX_C_DECIMAL_INTS    Y   //  "0|[1-9][0-9]*"                        CLEX_intlit4#define STB_C_LEX_C_HEX_INTS        Y   //  "0x[0-9a-fA-F]+"                       CLEX_intlit5#define STB_C_LEX_C_OCTAL_INTS      Y   //  "[0-7]+"                               CLEX_intlit6#define STB_C_LEX_C_DECIMAL_FLOATS  Y   //  "[0-9]*(.[0-9]*([eE][-+]?[0-9]+)?)     CLEX_floatlit7#define STB_C_LEX_C99_HEX_FLOATS    N   //  "0x{hex}+(.{hex}*)?[pP][-+]?{hex}+     CLEX_floatlit8#define STB_C_LEX_C_IDENTIFIERS     Y   //  "[_a-zA-Z][_a-zA-Z0-9]*"               CLEX_id9#define STB_C_LEX_C_DQ_STRINGS      Y   //  double-quote-delimited strings with escapes  CLEX_dqstring10#define STB_C_LEX_C_SQ_STRINGS      N   //  single-quote-delimited strings with escapes  CLEX_ssstring11#define STB_C_LEX_C_CHARS           Y   //  single-quote-delimited character with escape CLEX_charlits12#define STB_C_LEX_C_COMMENTS        Y   //  "/* comment */"13#define STB_C_LEX_CPP_COMMENTS      Y   //  "// comment to end of line\n"14#define STB_C_LEX_C_COMPARISONS     Y   //  "==" CLEX_eq  "!=" CLEX_noteq   "<=" CLEX_lesseq  ">=" CLEX_greatereq15#define STB_C_LEX_C_LOGICAL         Y   //  "&&"  CLEX_andand   "||"  CLEX_oror16#define STB_C_LEX_C_SHIFTS          Y   //  "<<"  CLEX_shl      ">>"  CLEX_shr17#define STB_C_LEX_C_INCREMENTS      Y   //  "++"  CLEX_plusplus "--"  CLEX_minusminus18#define STB_C_LEX_C_ARROW           Y   //  "->"  CLEX_arrow19#define STB_C_LEX_EQUAL_ARROW       N   //  "=>"  CLEX_eqarrow20#define STB_C_LEX_C_BITWISEEQ       Y   //  "&="  CLEX_andeq    "|="  CLEX_oreq     "^="  CLEX_xoreq21#define STB_C_LEX_C_ARITHEQ         Y   //  "+="  CLEX_pluseq   "-="  CLEX_minuseq22                                        //  "*="  CLEX_muleq    "/="  CLEX_diveq    "%=" CLEX_modeq23                                        //  if both STB_C_LEX_SHIFTS & STB_C_LEX_ARITHEQ:24                                        //                      "<<=" CLEX_shleq    ">>=" CLEX_shreq2526#define STB_C_LEX_PARSE_SUFFIXES    N   // letters after numbers are parsed as part of those numbers, and must be in suffix list below27#define STB_C_LEX_DECIMAL_SUFFIXES  ""  // decimal integer suffixes e.g. "uUlL" -- these are returned as-is in string storage28#define STB_C_LEX_HEX_SUFFIXES      ""  // e.g. "uUlL"29#define STB_C_LEX_OCTAL_SUFFIXES    ""  // e.g. "uUlL"30#define STB_C_LEX_FLOAT_SUFFIXES    ""  //3132#define STB_C_LEX_0_IS_EOF             Y  // if Y, ends parsing at '\0'; if N, returns '\0' as token33#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==N34#define STB_C_LEX_MULTILINE_DSTRINGS   N  // allow newlines in double-quoted strings35#define STB_C_LEX_MULTILINE_SSTRINGS   N  // allow newlines in single-quoted strings36#define STB_C_LEX_USE_STDLIB           Y  // use strtod,strtol for parsing #s; otherwise inaccurate hack37#define STB_C_LEX_DOLLAR_IDENTIFIER    Y  // allow $ as an identifier character38#define STB_C_LEX_FLOAT_NO_DECIMAL     Y  // allow floats that have no decimal point if they have an exponent3940#define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES  N   // if Y, all CLEX_ token names are defined, even if never returned41                                              // leaving it as N should help you catch config bugs4243#define STB_C_LEX_DISCARD_PREPROCESSOR    Y   // discard C-preprocessor directives (e.g. after prepocess44                                              // still have #line, #pragma, etc)4546//#define STB_C_LEX_ISWHITE(str)    ... // return length in bytes of whitespace characters if first char is whitespace4748#define STB_C_LEXER_DEFINITIONS         // This line prevents the header file from replacing your definitions4950#include "stb_c_lexer.h"