C++ TINY扩充正则表达式的语法
时间: 2023-11-27 21:47:50 浏览: 90
tiny-regex-c-master_C语言_master表达式_最小正则表达_
根据提供的引用内容,C++ TINY扩充正则表达式的语法如下:
1. program -> declarations stmt-sequence
2. declarations -> decl ; declarations | ε
3. decl -> type-specifier var-list
4. type-specifier -> int | bool | string | float | double | regex
5. var-list -> identifier { , identifier }
6. statement -> if-stmt | repeat-stmt | assign-stmt | read-stmt | write-stmt | while-stmt
7. while-stmt -> do stmt-sequence while bool-exp
8. bool-exp -> bool-term { or bool-term }
9. bool-term -> bool-factor { and bool-factor }
10. bool-factor -> [not] bool-primary
11. bool-primary -> identifier | literal | ( bool-exp ) | regex-exp
12. regex-exp -> / pattern /
13. pattern -> pattern-primary { pattern-concat pattern-primary }
14. pattern-primary -> character | . | ( pattern )
15. pattern-concat -> pattern-primary { pattern-primary }
16. character -> a | b | ... | z | A | B | ... | Z | 0 | 1 | ... | 9
其中,regex表示正则表达式类型,regex-exp表示正则表达式表达式,pattern表示正则表达式模式,pattern-primary表示正则表达式模式的基本单元,pattern-concat表示正则表达式模式的连接操作。
阅读全文