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

Suk Zhong sukmaillist at gmail.com
Thu Jul 9 02:55:20 PDT 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090709/c55b0e21/attachment.html>


More information about the webkit-dev mailing list