how lexical analysis determines scope?

F

free

As we all know,javascript is a lexical scope language.
Lexical analysis in addition to converting a sequence of characters
into a sequence of tokens , the scope is also determined when complete
lexical analysis.
how lexical analysis determines scope in detail?
scope chain ,variable declartion,function declartion .all is
determined?
 
L

Lasse Reichstein Nielsen

free said:
As we all know,javascript is a lexical scope language.
Lexical analysis in addition to converting a sequence of characters
into a sequence of tokens , the scope is also determined when complete
lexical analysis.

Not necessarily (or even typically). The scope is typically determined
by the *parser*, based on the grammar. It's true that you can often
determine the scope boundaries by simply counting '{' and '}' tokens,
but it's pretty useless since you can't determine what identifiers
correspond to a variable at the tokenizer level.

Javascript is even worse because tokenization depends on parsing in
order to distinguish division and regexp literals, so you need
feedback from a parser in order to correctly peform lexical analysis.
how lexical analysis determines scope in detail?

It doesn't.
scope chain ,variable declartion,function declartion .all is
determined?

None of this. That's a job for the parser.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top