RubyProgram = CompoundStatement EndOfProgram

EndOfProgram = EOF | NUL | CONTROL-D | CONTROL-Z

CompoundStatement = Statements [ Terms ].

BodyStatement = CompoundStatement [ RescueClause ] [ ElseClause ] [ EnsureClause ]

Statements = none | Statement | Statements Terms Statement | Error Statement

Terms = Term | Terms ;

Term = ; | Newline

Statement =
AliasStatement
| UndefStatement
| Statement if ExprValue
| Statement unless Expr
| Statement while Expr
| Statement unless Expr
| Statement rescue Statement
| BEGIN { CompoundStatement } # note: invalid inside method or singleton
| END { CompoundStatement }
| AssignmentStatement
| defined? [ Newline ] Arg
| Expression

Primary = Literal | String1 | XString | RegExp | Words | QWords | VarRef | BackRef | FieldName
| begin BodyStatement end
| ( Expr [ Newline ] ) # generates a warning: “(…) interpreted as grouped expression”
| ( CompoundStatement )
| Primary :: ConstName
| :: ConstName
| Primary [ ArefArgs ]
| [ ArefArgs ]
| { AssocList }
| return
| yield ( CallArgs )
| yield ( )
| yield
| defined? [ Newline ] ( Expr )
| Operation BraceBlock
| MethodCall [ BraceBlock ]
| IfStatement | UnlessStatement
| WhileOrUntilLoop
| CaseExpression
| for BlockVar in Expr Do CompoundStatement end
| class ClassPath SuperClass BodyStatement end
| class << Expr Term BodyStatement end
| module ClassPath BodyStatement end
| def FieldName FormalArglist BodyStatement end
| def Singleton ( . | :: ) FieldName FormalArglist BodyStatement end
| break
| next
| redo
| retry

Then = Term | : | then | Term then

Do = Term | : | do

Singleton = VarRef | ( Expr [ Newline ] )

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: