Domanda
Sto cercando la grammatica di Ruby in forma BNF. Esiste una versione ufficiale ?
Soluzione
Sì, esiste una Sintassi Ruby BNF da parte della Università del bufalo.
Modifica: ho anche trovato questo alternativo Sintassi Ruby BNF .
Altri suggerimenti
La sintassi YACC è nella fonte Ruby. Scaricalo ed esegui l'utilità in bundle per ottenere la sintassi leggibile.
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
Esempio di output (totale 918 righe per la versione 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
;
anche una versione ufficiale: Ruby Draft Specification. puoi trovare la grammatica lì.
Specifiche del progetto Ruby: http://ruby-std.netlab.jp . il server è inattivo, ma è possibile scaricarlo da http://www.ipa.go.jp/osc/english/ruby
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow