In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge points about the analysis of the operation principle of JavaScript. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Scanner
The source code is first decomposed into chunk, and each chunk may have a different encoding, and later there will be a character stream that unifies the encoding of all chunk into UTF-16.
Before parsing, the scanner splits the UTF-16 character stream into token. Token is the smallest unit with semantics in a script. There are different types of token, including white space characters (for automatically inserting semicolons), identifiers, keywords, and proxy pairs (which are combined into identifiers only if the proxy pair cannot be recognized as something else). These token are then sent to the pre-parser and then to the parser.
Pre-parser
The parser has the least amount of work, as long as it is enough to skip the incoming source code and do lazy parsing (rather than full parsing). The pre-parser ensures that the input source code contains valid syntax and generates enough information to compile the external function correctly. The prepared function will be compiled on demand later.
Analysis
After the parser receives the token generated by the scanner, it now needs to generate an intermediate representation for the compiler to use.
First, let's talk about parsing trees. A parsing tree, or concrete grammar tree (CST), represents the source syntax as a tree. Each leaf node is a token, while each intermediate node represents a syntax rule. In English, grammar rules refer to nouns, subjects, etc., while in programming, grammatical rules refer to an expression. However, the size of the parse tree increases rapidly with the program size.
On the contrary, the abstract syntax tree is more concise. Each intermediate node represents a structure, such as a subtraction operation (-), and the tree does not show all the details of the source code. For example, groups defined by parentheses are contained in the structure of the tree. In addition, punctuation, delimiters and white space characters are omitted. You can learn more about the difference between AST and CST here.
Next we will focus on AST. Take the following Fibonacci program written in JavaScript as an example:
Function fib (n) {if (n)
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.