How do I peel off an interpreter's execution part?

Source: Internet
Author: User
If you want to keep the executable part of the interpreter on a resource-constrained embedded device, separate the rest.
How do you analyze an interpreter and sort out its execution parts?

Reply content:

The main question of the JavaScript engine is Espruino , the interpreter is very, very, very small, and I wonder what else the master needs to strip out?

The execution part of this JavaScript engine is an interpreter, and it is the kind of interpretation that is interpreted by the parse side, even if the AST is not constructed. This way of realization reminds me of the earliestThe PHP ... This is one of the slowest ways to implement the interpreter ...
So its interpreter body is in this file:
Espruino/jsparse.c at Master Espruino/espruino GitHub
It relies on Jslex. [H|c] and Jsvar. [H|c]. Jslex is responsible for lexical analysis, Jsvar is responsible for memory management (including the definition of object structure and an ultra-simple mark-sweep GC, etc.).

The remaining files in the SRC directory,
    • Jswrap begins with the implementation of the JavaScript standard library, which can be deleted if it is not useful;
    • Then the remainder of the JS file (for example, Jsdevice. [H|c]) are mainly related to the operation of embedded devices, these can also be seen in the main needs of the cutting.

In other words, there is a JavaScript implementation that does not construct the AST directly as interpreted by the parse side, Tiny-js , also very small. Official website: Pur3.co.uk:: Tinyjs
And it is actually the predecessor of Espruino's JavaScript implementation. No wonder the same idea will be used to achieve ... Uh
Espruino-press
As
a Linux user Gordon was aware this whatever tools were used had to work reliably on multiple platforms without NE Eding extra software, so building a interpreter into the microcontroller seemed the obvious. BASIC interpreters for microcontrollers has been around for a while (like The amazing maximite), but until recently the A Mount of built-in RAM and Flash in microcontrollers have been a stumbling block for more complex languages. When Gordon saw the STM32F1 development boards with 128kb of Flash and 8kb of RAM he realised he could use the lessons Lea Rned from He tinyjs JavaScript interpreter (originally built for Morphyre) to produce something that would run within tho Se limits-and so Espruino started!

====================================

The main question of the Python interpreter Micropython It looks bigger than Espruino. It includes at least a very complete compiler + bytecode interpreter, +GC, which is not much of a thing to crop. The main active is the external library ...
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.