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 ])* 
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

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

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

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

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

Python正则表达式指南

本文介绍了Python对于正则表达式的支持,包括正则表达式基础以及Python正则表达式标准库的完整介绍及使用示例。本文的内容不包括如何编写高效的正则表达式、如何优化正则表达式,这些主题请查看其他教程...

python正则表达式

  • 2017-05-16 16:06
  • 6.87MB
  • 下载

Python爬虫基础-5(正则表达式)

Python支持的正则表达式元字符和语法: 语法 说明 表达式实例 完整匹配的字符串 字符 一般字符 匹配自身 abc abc . 匹配除换...

Python中关于正则表达式

  • 2016-01-11 19:29
  • 54.88MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

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