the regex i am using is for an implementation of preprocessor, in flex. This preprocessor is kindof simple. It obeys following rules:
- the preprocessor directive starts with #define followed by identifier in capital letters
- the use-case of preprocessor identifier begins with a
#
sign.
for example:
#define CONSTANT 100
//...
int x = #CONSTANT;
so first thing i did was
#define {
//store the identifier following #define in a lookup table
//do the relevant error checking
}
NO_POUND_DEFINE {
//The string should begin with a '#' sign but not with `#define`
//check if the string following '#' is upper case or not
//if in upper case do the lookup otherwise throw an error
}