我正在寻找 BNF 形式的 Ruby 语法。有正式版吗?
问问题
12041 次
3 回答
35
YACC 语法在 Ruby 源代码中。下载它并运行捆绑的实用程序以获得可读的语法。
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
tar xvzf ruby-2.0.0-p195.tar.gz
cd ruby-2.0.0-p195
ruby sample/exyacc.rb < parse.y
输出样本(v2.0.0-p195 共 918 行)
program : top_compstmt
;
top_compstmt : top_stmts opt_terms
;
top_stmts : none
| top_stmt
| top_stmts terms top_stmt
| error top_stmt
;
top_stmt : stmt
| keyword_BEGIN
'{' top_compstmt '}'
;
bodystmt : compstmt
opt_rescue
opt_else
opt_ensure
;
compstmt : stmts opt_terms
;
于 2013-05-18T21:49:38.040 回答
15
是的,布法罗大学有一种Ruby BNF 语法。
编辑:我还发现了这种替代的Ruby BNF 语法。
于 2009-03-19T16:55:05.397 回答
5
还有一个正式版本:Ruby Draft Specification。你可以在那里找到语法。
Ruby 草案规范:http ://ruby-std.netlab.jp 。服务器已关闭,但您可以从 http://www.ipa.go.jp/osc/english/ruby下载它
于 2011-07-07T04:29:18.320 回答