

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!
Based on
http://docs.huihoo.com/ruby/ruby-man-1.4/yacc.html
with some edit-
ing. I have found other websites attesting that Ruby version 1.4.6 is the latest with a reference manualin English,
http://docs.huihoo.com/ruby/ruby-man-1.4/index.html
, though Ruby
exists up to v1.9 in Japanese.
ALL-CAPS are used for nonterminals, and all-lowercase for literal keywords. Literal
are quoted to distinguish them from BNF syntax.
PROGRAM
"\n"
//a newline can
terminate a statement
CALL do
["|" [BLOCK_VAR] "|"] COMPSTMT end
undef FNAME |^
alias FNAME FNAME |^
STMT if
STMT while EXPR |^
STMT unless EXPR |^
STMT until EXPR |^
//object initializer
//object finalizer
COMMAND [do
["|" [BLOCK_VAR] "|"] COMPSTMT end]
return CALL_ARGS |^
yield CALL_ARGS |^
EXPR and EXPR |^
EXPR or
not EXPR |^
super CALL_ARGS
super "(" [CALL_ARGS] ")" |^
super
defined? ARG |^
return ["(" [CALL_ARGS] ")"] |^
yield ["(" [CALL_ARGS] ")"] |^
defined? "(" ARG ")" |^
if EXPR THEN
{elsif EXPR THEN
[else
end |^
unless EXPR THEN
[else
end |^
while EXPR DO COMPSTMT end |^
until EXPR DO COMPSTMT end |^
case COMPSTMT
when WHEN_ARGS THEN COMPSTMT{when WHEN_ARGS THEN COMPSTMT} [else
end
for BLOCK_VAR in
end |^
begin
{rescue [ARGS] DO
[else
[ensure
end |^
class IDENTIFIER [< IDENTIFIER]
end |^
module IDENTIFIER
end |^
def FNAME ARGDECL
end |^
def SINGLETON (.
end
| then |
then
//"then" and "do" can go
on next line
| do
do
nil |
self
numeric |
The following are
recognized by the lexical analyzer.
$any_char |
$-any_char
" {any_char} " |^
’ {any_char} ’ |^
‘ {any_char} ‘
%(Q|q|x)char {any_char} char
{any_char}IDENTIFIER
/ {any_char} /
[i|o|p]
%r char {any_char} char
sequence in
/[a-zA-Z_]{a-zA-Z0-9_}/.