- Compiler theory
- Word / lexical analyzer tokenizing / lexing
- Code string decomposition, as
var a = 2;
will be decomposed to var, a, =, 2, ;. Each individual element to the lexical unit (token). - Spaces whether as a lexical unit, to see whether it makes sense spaces.
- Lexical unit generator determines whether a part of other lexical units, called a stateful parsing rule, this process is the lexical analysis. If you are stateless, that word.
- Code string decomposition, as
- Parsing / syntax analysis
- This method elementary stream (array) is converted into an abstract syntax tree. As shown below
- This method elementary stream (array) is converted into an abstract syntax tree. As shown below
- Code Generation
- The AST is converted to executable code process.
- About to write code that translated into a set of machine instructions, create variables, memory allocation, and the value stored therein.
- The AST is converted to executable code process.
- For var a
- Word / lexical analyzer tokenizing / lexing
- Understand the scope of
- engine
- Compile and execute programs
- translater
- Parsing and code generation
- Scope
- Collect and maintain a list of all identifiers of inquiry to determine the code currently executing access to these identifiers
- Assignment of variables
- The compiler to declare a variable in the current scope (if not previously declared); engine to find the variable scope is running, can be found on its assignment
- engine
- LHS and RHS
- Variable on the left side of an assignment, a LHS inquiry; the right RHS
- RHS query is to find the value of a variable, LHS inquiry is to find a variable container, so you can assign it a value
console.log(a); // RHS
To find the value of a
a = 2; //LHS
Find a target (container) this assignment is = 2
- ```js
function foo(a) {
console.log( a ); // 2
}
foo(2);
- The last line foo (..) call, RHS quote, because to find the value of foo
- When the parameter passing, a = 2 implicit operations, the LHS query, lookup vessel 2 =
- console.log (a) the value of a query RHS
If the console.log () may receive parameters, the 2 (RHS above to find the value of a query) assigned to arg1, parameter 1 is LHS.
`` `LHS is a function declaration or RHS?
- Variable on the left side of an assignment, a LHS inquiry; the right RHS
- Nested scopes
- A scope is used to determine where and how to find the rule identifier.
- why lhs & rhs?
- For undeclared variables
- 23
- If it is LHS, shall be assigned container
- If strict mode, ReferenceError
- If a non-strict mode automatically creates a variable (global scope), returned to the engine.
- If it is RHS, can not find the value, ReferenceError
- Exercise
- Where the right identifier (not a number, including function identifier and a different binary representations of numbers). RHS should be carried out
What scope is?
Guess you like
Origin www.cnblogs.com/wydumn/p/11575488.html
Recommended
Ranking