In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the function of the interpreter of javascript". In the daily operation, I believe that many people have doubts about the role of the interpreter of javascript. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what is the role of the interpreter of javascript?" Next, please follow the editor to study!
Javascript interpreter, also known as "JavaScript engine", is a virtual machine dedicated to processing JavaScript scripts, which is usually attached to web browsers; JavaScript interpreter has four components: lexical analyzer, syntactic parser, bytecode generator, and bytecode interpreter.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
What is the javascript interpreter?
JavaScript is a scripting language that needs to be interpreted and executed by others, who is the JavaScript interpreter. It reads a JS statement, translates, executes, and then reads the next JS statement over and over again.
The JavaScript interpreter, also known as the JavaScript engine, is a virtual machine that specializes in processing JavaScript scripts and is usually included in web browsers. Its function is to execute the JavaScript source code.
The JavaScript parsing engine is a program that can "read" the JavaScript code and accurately give the results of the code.
The composition of JavaScript interpreter
The JavaScript interpreter has four components: lexical parser, syntactic parser, bytecode generator and bytecode interpreter.
Lexical parser
It allows lines of source code to be split into the smallest semantic units. The so-called semantic unit is the smallest single character or character combination that can no longer be divided grammatically.
Var number = 2 / / parsed to the following json format [{'type':'keyword',' value':'var'}, {'type':'identifier',' value':'number',}, {'type':'Punctuator',' value':'=',}, {'type':'Numeric' 'value':'2',} {' type':'Punctuator', 'value':' '}]
Syntactic parser
The above analysis of the array, according to the syntax rules, into an abstract syntax tree, using Esprimas parsing tool can know that it has also been converted into json format.
What is the use of this abstract grammar tree?
People say they compress and optimize the code, which I don't understand, and then they say that compilers, IDE, etc., all have many uses (there is no way to go deep into the skills now)
In Meituan Dianping's technology, we see that syntax trees can be used to ReFactor javaScript code.
Bytecode generator
Its function is to convert the syntax tree into binary code that the javaScript engine can read and execute.
Each javascript engine has its own bytecode format, and the easiest way is to translate semantic units into binary
Bytecode interpreter
Of course, this one-ring and one-ring has the binary code, so the next step is to execute the binary code, resulting in a result that you can see with your eyes.
At this point, the study of "what is the role of the interpreter of javascript" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.