Hello. I began to get acquainted with ruby ​​and the following question arose: (subject)

How does chop work?

Are there articles where you can read, how is interpretation implemented? How is the code parsed? And in general, what happens when you launch a file, code, program?

  • 3
    "interpretation", "parses", commas. Learn Russian first. - pirj
  • four
    @pirj I would not say that the word "interpretation" is Russian, well, and the word "parsit" is generally absent in Russian. On the other hand, yes, children's mistakes - DreamChild
  • one
    In fact, the only reliable description of the program is its source code. - avp
  • Remember the difference from other languages ​​- in Ruby the code is executed from top to bottom line by line. And during this execution, classes / methods are declared, etc. - vitidev

1 answer 1

Read about lexical and syntactic analysis. A classic work on building compilers is the " Book of the Dragon ", but it is difficult to understand and requires some mathematical basis. I can advise chapters 24 and 29 of G. Shildt’s book Complete C Reference , explain the principles of parsing expressions and write a simple interpreter of the subset C. The principles described there can be applied to other programming languages, including Ruby.