Question
Je recherche la grammaire Ruby sous forme BNF. Existe-t-il une version officielle ?
La solution
Oui, il existe une syntaxe Ruby BNF fournie par le Université de buffle.
Modifier: j'ai également trouvé cette alternative Syntaxe Ruby BNF .
Autres conseils
La syntaxe YACC est dans le source Ruby. Téléchargez-le et lancez l'utilitaire fourni pour obtenir la syntaxe lisible.
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
Exemple de sortie (918 lignes au total pour la version 2.0.0-p195)
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
;
également une version officielle: Ruby Draft Specification. vous pouvez y trouver la grammaire.
Spécification brouillon Ruby: http://ruby-std.netlab.jp . le serveur est en panne, mais vous pouvez le télécharger à partir de http://www.ipa.go.jp/osc/english/ruby
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow