[webkit-dev] how to understand the grammar implemention of js script "var a=9; "?

Maciej Stachowiak mjs at apple.com
Thu Jul 9 03:02:34 PDT 2009


This mailing list is for discussing the development of WebKit. For  
help in using WebKit, please post to <webkit-help at lists.webkit.org>.

On Jul 9, 2009, at 2:55 AM, Suk Zhong wrote:

> Hi All:
>    I want to understand the javascript grammar from Grammar.y in  
> JavascriptCore,for the script "var a=9;",we find the following code:
>    VariableStatement:
>         VAR VariableDeclarationList ';' {...}
>
>    VariableDeclarationList:
>         IDENT                           {...}
>         | IDENT Initializer             {...}
>    Initializer:
>     '=' AssignmentExpr                  { $$ = $2; }
>
>    AssignmentExpr:
>      ConditionalExpr
>      | LeftHandSideExpr AssignmentOperator AssignmentExpr {...}
>
>    in my understand, '9' maybe be as Literal/PrimaryExprNoBrace/ 
> PrimaryExpr/MemberExpr/LeftHandSideExpr etc,but why can be converted  
> as AssignmentExpr?
>
>    in the script "a=b;", i also encounter the same case, why the 'b'  
> can be converted as AssignmentExpr?
>
>    the following update can be correct?
>    AssignmentExpr:
>      ConditionalExpr
>      |LeftHandSideExpr
>      | LeftHandSideExpr AssignmentOperator AssignmentExpr {...}
>
>    someone can help me understand the grammar?
>
> Thanks and Best Regards
>
> Suk
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev



More information about the webkit-dev mailing list