|
|
how lexical analysis determines scope?
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?
|
|
0
|
|
|
|
Reply
|
free
|
3/26/2011 6:23:58 AM |
|
free <sheng.yonggeng@gmail.com> writes:
> 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
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'
|
|
0
|
|
|
|
Reply
|
Lasse
|
3/26/2011 10:49:39 AM
|
|
|
1 Replies
284 Views
(page loaded in 0.04 seconds)
|
|
|
|
|
|
|
|
|