What opcode dispatch strategies are used in efficient interpreters?

后端 未结 8 1614
花落未央
花落未央 2020-12-29 13:27

What techniques promote efficient opcode dispatch to make a fast interpreter? Are there some techniques that only work well on modern hardware and others that don\'t work we

8条回答
  •  盖世英雄少女心
    2020-12-29 13:57

    The question is a bit vague. But, it seems you're asking about writing an interpreter.

    Interpreters typically utilize traditional parsing components: lexer, parser, and abstract syntax tree (AST). This allows the designer to read and interpret valid syntax and build a tree structure of commands with associated operators, parameters, etc.

    Once in AST form, the entire input is tokenized and the interpreter can begin executing by traversing the tree.

    There are many options, but I've recently used ANTLR as a parser generator that can build parsers in various target languages, including C/C++ and C#.

提交回复
热议问题