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 ...