c++正则表达式,python

原创 2007年10月03日 21:32:00
一个python中国列表的朋友给的
------------------------------------------------------------------------------------------------------------------------------------------
C++ grammar summary

Execution parts:

////////////////////////Well-known definitions: (They do only their business, any stuff not belong to them will be not processed)
blank: /s*
strictblank: /s+
number: OR:
           r"[/d]+",r"[.][/d]+",r"[/d]+[.][/d]*",
             r"[/d]+[.]?e(?:[+]|-|)[/d]+",r"[.]?[/d]+(?:e|E)(?:[+]|-|)[/d]+",
             r"[/d]+[.][/d]*e(?:[+]|-|)[/d]+",
             r"0[xX][0-9a-fA-F]+", #Hex number
             r"0[0-8]+", #Octal number
             r"'[^']+'"
string: "(?:[^//]|//.)+"
value: [bool|number|string]
literal: [a-zA-Z_][0-9a-zA-Z_]*
bool: [true|false]

////////////////////////Semi-atom level definitions: (iterates will process all begin blank but no after blanks will be processed)
type: literal (blank :: blank literal)*
valueiterate: (blank(operators|operator,|value|literal| [(] strictvalueiterate blank [)]))*
strictvalueiterate: (blank(operators|operator,|value|literal| [(] strictvalueiterate blank [)]))+
passvalueiterate: (blank(operators|value|literal| [(] strictvalueiterate blank [)]))*
strictpassvalueiterate: (blank(operators|value|literal| [(] strictvalueiterate blank [)]))+
operators: OR:
               "new","delete","delete" blank [ blank ],"++","--","<<",">>",
               "!","&&","||",">=","<=",">","<","!=","==",
               "+=","-=","*=","/=","%=",
               "^=","&=","|=",
               "->",",",
               ".","::",
               "^","&","|","~",             
               "+","-","*","/","%",
               "[","]","(",")"

assignname: (blank [*|&])* blank literal (blank [ blank /d* blank ] )*

assignvaluector: blank [(] (blank strictpassvalueiterate (blank , blank strictpassvalueiterate)+)? [)]
assignvaluecopy: blank = blank strictpassvalueiterate
assignvaluevoid:
assignvalue: ( assignvaluector | assignvaluecopy | )
valuesingledefinition: blank type blank assignname (assignvaluector | assignvaluevoid)

functionspecifier: (blank [inline|virtual|explicit|auto|register|static|extern|mutable|extern|static])*

////////////////////////Atom level definitions: (Every thing that can be treated as a language sentence) (only begin either)
valueblock: valueiterate blank ;
if: blank "if/b" blank ( strictvalueiterate blank ) [sentencelite|sentenceblock]
for: blank "for/b" blank ( [valuesingledefinition|passvalueiterate] blank ; passvalueiterate blank ; passvalueiterate blank ) [sentencelite|sentenceblock]
while: blank "while/b" blank ( strictvalueiterate blank ) [sentencelite|sentenceblock]
do: blank "do/b" blank sentenceblock blank while blank ( strictvalueiterate blank ) blank ;
break: blank "break/b" blank ;
return: blank "return/b" [strictvalueiterate|] blank ;

sentencelite: blank [break|return|valueiterate blank ;]
valueassign: blank type blank assignname assignvalue (blank , assignname assignvalue)* blank ;
sentence: [sentencelite|valueassign]

////////////////////////Segments: (only begin either)
sentenceblock: blank { blank (sentence)* blank }
structblock: blank { blank [public:|private:|valueassign|function|struct|structdef] blank }

////////////////////////First class objects:
function: blank functionspecifier blank type blank ( blank (valuesingledefinition (blank , valuesingledefinition)* )? blank )
          [(blank : blank type blank "(" sentence blank ")" (blank , blank type blank "(" sentence blank ")")*)? sentenceblock|;|= blank 0 blank ;]
namespace: blank "namespace" blank literal blank { blank document blank }
usenamespace: blank use blank "namespace" blank literal blank ;
struct: blank ["struct"|class|union] blank literal [blank : (blank [public|private|protected|] blank literal (blank , blank [public|private|protected|] blank literal)*)? structblock ( blank assignname assignvalue (blank , assignname assignvalue)*)? blank ;
structdef: blank ["struct"|class|union] blank literal blank ;
document: (blank [ valueassign|function|namespace|struct|structdef ])* 

正则表达式使用学习(C++、Qt、Python)

写在前面 个人对于正则表达式实在是不太了解,所以本文内容纰漏应该会比较多。只希望不会对大家造成误导。 本文只是简单涉及C++0x、Qt4、Python3、Vim中的正则表达式: ...

Windows 下正则表达式库 re2 在 C++ 和 Python 中的编译和使用

相信平时在工作或学习中需要处理大量正则表达式的同志们对 google 大名鼎鼎的 re2 模块一定不陌生,但之前在网上进行搜索时,很多人说无法在 windows 系统使用该模块。本文简述了 windo...

python 正则表达式

  • 2017年11月28日 16:18
  • 228KB
  • 下载

Python3 如何优雅地使用正则表达式(详解六)

修改字符串 我们已经介绍完如何对字符进行搜索,接下来我们讲讲正则表达式如何修改字符串。 正则表达式使用以下方法修改字符串: 方法 用途 split...

Python正则表达式指南.pdf

  • 2017年11月10日 16:29
  • 940KB
  • 下载

正则表达式分组与python收集系统ip

.* 代表匹配任意字符,贪婪模式,就是尽可能的向后匹配 .*? 这个能阻止贪婪模式re 修饰符: 修饰符 描述 re.I 使匹配对大小写不敏感 re.L 做本地化识别(locale-awar...

python正则表达式

  • 2017年05月16日 16:06
  • 6.87MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:c++正则表达式,python
举报原因:
原因补充:

(最多只允许输入30个字)