Regex 以“开始”开头的所有文本的正则表达式#&引用;但不是用#定义
我使用的正则表达式用于flex中预处理器的实现。 这个预处理器有点简单。 它遵守以下规则:Regex 以“开始”开头的所有文本的正则表达式#&引用;但不是用#定义,regex,lex,Regex,Lex,我使用的正则表达式用于flex中预处理器的实现。 这个预处理器有点简单。 它遵守以下规则: 预处理器指令以#define开头,后跟大写标识符 预处理器标识符的用例以#符号开头 例如: #define CONSTANT 100 //... int x = #CONSTANT; 所以我做的第一件事就是 #define { //store the identifier following #define in a lookup table //do th
#
符号开头#define CONSTANT 100
//...
int x = #CONSTANT;
所以我做的第一件事就是
#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
}
^defin[^e]([^d]| d[^e]| de[^f]| def[^i]| defi[^n]| defin[^e])。
字符串以“|”开头,不后跟“d”,或后跟“d”,但不后跟“e”等
var regexp = /^((?!#define).)*$/;
也许你想看看这个:什么语言?那么
中的#define
与lex版本2.5.4中的#define
相匹配如何?它说的是无法识别的规则。是的,lex可能不喜欢Perl的rexes,因为性能原因很明显;-)