注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

中吴南顾惟一笑

成功法则就是那19个字

 
 
 

日志

 
 

Syntax Diagram的使用  

2010-06-03 13:48:26|  分类: dbms |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
http://bugs.mysql.com/bug.php?id=18877

   Syntax Diagram( 语法图)是描述形式文法的一种图形化表示方式。在编译领域,像BNF及其变体这样的文字式表示法都是首选。但它不能很好的被这些语言的大部分用户理解。语法图通过一种直观的方式定义了这门语言:属于这门语言的每句话都必须在图上描绘出一个路径。数据交换格式JSON之所以流行的部分原因就是它是用语法图来表示的。
    语法图对于SQL语法表示尤其有效。可以按照箭头指引的方向,从左到右的方式来读。
    所以在mysql上看到有人提的一个有意思的bug,Keith Roberts建议用脚本及时更新语法,就像sqlite一样。sqlite是用的是TCL脚本。
网上搜了一下BNF到Syntax Diagram的转换工具,极少,只有一个ebnf2ps,还是用Haskell写的。ANTLRWorks也算一个吧,有空试用一下。
[7 Apr 2006 9:38] Keith Roberts
Description:
I would like to suggest some ways of keeping the documentation of mysql
syntax changes up to date, as those changes are made by the developers
of mysql.

Any changes made to the internals of mysql may not be immediately
apparent, or of any particular concern, to joe bloggs average user of
mysql.

As the syntax is joe bloggs way of communicating with mysql, he needs
to know about these changes right away.

IMHO, There needs to be some sort of methodology in place that will
ensure changes made to mysql syntax are properly documented by the
developers as those changes are made.

How can this be accomplished?

Well, I did start Jack Crenshaw's "Let's build a compiler" course,
around 98-98. http://compilers.iecc.com/crenshaw/

(I realise that Jack only covers top-down resursive-descent one-pass
compilation techniques, and hand written parsers, but I'm sure that the
method mentioned below is applicable to other types of parsers as well.)

One of the tips Jack mentions is how to go about designing your parser.

He suggests that parser design is first done using BNF syntax diagrams.
(IIRC he actually suggests the use of XBNF diagrams.)

Then use the BNF (or XBNF) as a blueprint to convert that particular syntax
construct into parser code.

By using this method, all mysql syntax documentation is guaranteed to be
up to date, as the documentation is actually designed first, before
changes to the code have been implemeted. Bearing this idea of Jack's in
mind, may I suggest the following methodology for documenting the changes
made to mysql syntax.

1. Changes to the mysql syntax are limited to core parser developers of
MySQL AB only.

(Maybe there needs to be a small team of MySQL AB persons that are
directly responsible for implementing changes to the mysql syntax,
using the method mentioned above.)

2. Anyone can make suggestions to improve mysql syntax, by submitting a bug
report.

3. Only the MySQL AB parser team can implement changes to mysql syntax,
whether it be suggestions submitted via a bug report, or ideas from any
other sources.

4. The parser team designs the new mysql syntax with (X)BNF diagrams.

5. The syntax changes are made to the mysql program code by the parser
team, or a member of the team.

6. The changes are tested and approved for inclusion in the next release of
mysql.

7. When the changes have been approved for the next release, the (X)BNF is
then passed along to Stefan Hinz for inclusion in the reference manual.

Hopefully, this will keep all changes to mysql syntax current and up to
date.

Kind Regards

Keith Roberts

How to repeat:
Just test the documented syntax using the mysql monitor program.

Suggested fix:
Limit mysql syntax changes to a small number of core developers only, and use some sort
of methodology for implementing those syntax changes that will ensure those changes are
properly documented as soon as they have been implemented and accepted into the next
release of mysql.
  评论这张
 
阅读(693)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017