In the interpreter, what (usually) comes after lexer?

For the interpreter of a programming language, I am interested in learning about the sequence of events that the interpreter goes through. For example, I think the way it is:

  • The interpreter gets some input
  • The lexicon / tokenizer receives input and delimits tokens
  • x gets a list of tokens
  • ???
  • Code is running

Which step belongs? spot and what happens instead of x (that is, what gets and acts on the tokens that the lexer gave)?

+3
source share
3 answers

I will start by recommending a classic and free book: The structure and interpretation of computer programs ( video lectures )

Lisp - , .

, :

  • char
  • ( ) , (AST). (Lisp) (++, Ruby).
  • AST. , , . data (, , , ) - (, , ), . node , node .

- " ". Just-In-Time (JIT) AST . , . , c--, LLVM,.NET Java bitecode. - / , . , Haskell , .

, ( Lisp). , , .

+2

, , , . , , :

( x + 4 ) * 3

, . . if { } , if, , . , ; - .

:

    *
  +   3
 x y

- x y .

, , :

( p && q ) { foo ; bar ; } else { baz ; }

:

IfStatement:
  Condition:
    LogicalConjunction:
      LeftOperand: p
      RightOperand: q
  TruePart:
    BasicBlock:
      Statement: foo
      Statement: bar
  FalsePart:
    BasicBlock:
      Statement: baz

, , , .

, , .

+2

  • p-

executor p- .. .

, , p-code, , , , .., , p-.

p- , .

+1

All Articles