Вы находитесь на странице: 1из 3

Assignment statement:

In Ruby assignment uses the ‘=’ (equals sign) character. Belows are syntax of assignment
statement:

Assignment expression are used to assign objects to the variables or such. Assignments sometimes work
as declarations for local variables or class constants. The left hand side of the assignment expressions
can be either:

 Variable

If the left hand side is a variables, then assignment is directly performed.

 Array reference

This from is evaluated to the invocation of the method named []=, with expr1 as the receiver, and values
expr2 to exprN as arguments.

 Attribute reference

This from is evaluated to the invocation of the method named identifier= with the right hand side
expression as a argument.

 Self assignment

 Multiple assignment
Intepreter:

Unlike compilers which pre-translate source code into machine code before a program runs,
interpreters translate code as they are executing it, line-by-line. Continuing with the previous analogy,
computer interpreters are like, well, interpreters. They serve as the interface between a Spanish and
English speaker interacting in real time, interpreting the language sentence by sentence.

The default Ruby interpreter was Ruby MRI, also known as CRuby. Ruby MRI stands for Matz’s Ruby
Interpreter (named after "Matz," or Yukihiro Matsumoto, the chief designer of Ruby), whereas YARV
(Yet-Another Ruby Virtual machine) uses a stack to parse Ruby code, CRuby uses an abstract syntax tree.

YARV:

First, Ruby will tokenize your code into tokens. These token will be parsed into Abstract Syntax Tree
(AST) Node. Then AST nodes will be compiled into bytecodes - form of instruction set. Bytecodes will be
run in Ruby Virtual Machine
After tokenizing, your code transformed into tokens. Then Ruby will parse into meaningful sentence,
phrases. Ruby use parser generator named Bison, Bison will produce parser is parse.c thourgh parse.y

Parse.c will parse code Ruby into AST Nodes and compiled it into byte code, for Ruby virtual machine
executes. The parsing algorithms used is LALR (Look Ahead Left-reserved Right-most deviration)

The bytecodes are YARV (Yet Another Ruby VM) instructions. Structure of YARV instruction. YARV is
actually Stack-oriented VM,in the other way, YARV use value stack (contain arguments and values) to
execute YARV instruction, (push executable value into stack or pop out the values out of stack).

Вам также может понравиться