Spidermonkey And narcissus syntax analysis

Source: Internet
Author: User

Narcissus is a js interpreter written by js, but the underlying layer still depends on spidermonkey. Therefore, with zaphod, zaphod can easily switch the spidermonkey of firefox to narcissus.

Now narcissus can only run on firefox's beta1-beta8, so first go to firefox's beta browser. Reference Web site https://mozillalabs.com/zaphod/

----------------------------------------- Zaphod for narcissus
For day to day browsing, Narcissus does not offer any real advantages over SpiderMonkey. However, Narcissus is an ideal tool for developing new ideas for the JavaScript language itself.

Zaphod promises to be a great tool for getting hands-on experience with experimental JS language features. initially, it will useful to us internally for rapidly piloting language features in the browser. down the road, it may also become a vehicle for giving the community early access to these ideas, so they can try them out and give us feedback. and of course, it's all open source, so anyone who wants to join in on the effort is most welcome.

Spidermonkey is the js interpretation engine of firefox. There is a parse api that can parse js
------------------------------------------- Spidermonkey parse api

An independent spidermonkey script makes it easier to manipulate js source code in js, such as syntax highlighting, static analysis, interpretation, and compilation.
Https://developer.mozilla.org/en/SpiderMonkey/Parser_API

Install in ubuntu
First install Library
Sudo apt-get install libnspr4-dev

Source code installation manual -------------------- this latest only 1.81, there is no parse method in this
Download source code
Mkdir mozilla
Cd mozilla
Wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
Tar xzf js-1.7.0.tar.gz
Then compile
Cd js/src
Make-f Makefile. ref
Now there is a js under the Linux_ALL _... folder. That's it.
How can I directly install it on the system? Http://ebixio.com/blog/2010/07/31/how-to-install-libjs-spidermonkey/

Simple installation of source code -------- this method is recommended for the latest 1.85
Hg clone http://hg.mozilla.org/mozilla-central/
Cd js/src
Autoconf2.13
./Configure
Make

Usage
Https://developer.mozilla.org/En/SpiderMonkey/Introduction_to_the_JavaScript_shell

js> Reflect.parse("function a(){  var b=2;  function c(){    var ci=3;ci+=b}}",{loc:false})

Result

({ type:"Program", body:[ {  type:"FunctionDeclaration",  id:{ type:"Identifier", name:"a"},   params:[],   body:{    type:"BlockStatement",   body:[{ type:"VariableDeclaration",  kind:"var",  declarations: [{  type:"VariableDeclarator",  id:{ type:"Identifier", name:"b"},  init:{ type:"Literal", value:2}  }] },       { type:"FunctionDeclaration", id:{ type:"Identifier", name:"c"}, params:[],  body:{   type:"BlockStatement",   body:[{ type:"VariableDeclaration",  kind:"var",  declarations:[{   type:"VariableDeclarator",   id:{ type:"Identifier", name:"ci"},    init:{ type:"Literal", value:3}}]},     {   type:"ExpressionStatement",   expression:{    type:"AssignmentExpression",    operator:"+=",    left:{  type:"Identifier", name:"ci"},    right:{ type:"Identifier",  name:"b"}             }   }   ]},       generator:false,       expression:false    }  ]},  generator:false,   expression:false}]})

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.