Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Goでインタプリタつくった

 Goでインタプリタつくった

"Writing An Interpreter In Go" https://interpreterbook.com/
をよんでインタプリタつくった。ただそれだけの話。

Avatar for vortispy

vortispy

March 05, 2017
Tweet

Other Decks in Programming

Transcript

  1. 概要 • “Writing An Interpreter In Go”を読んでインタプ リタつくった • Go言語しか使わない

    • GotoutineやChannelは使わない • 難しいことは気にせずとりあえず作ってみる
  2. let a = 1; if (a > 10) { return

    a; } <LET><IDENT><ASSING><INT><SEMICOLON> <IF><IDENT><GT><INT><LBRACE> <RETURN><IDENT><SEMICOLON> <RBRACE>
  3. 評価 • ASTを解釈して実行する • どのように解釈させるか? • 例: “foo” * 3

    • Python: “foofoofoo” • Go: cannot convert "foo" to type int invalid operation: "foo" * 3