Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implementation of Mozilla's Parser API in JavaScript

NotificationsYou must be signed in to change notification settings

zaach/reflect.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reflect.js

Reflect.js is a JavaScript (ES3 compatible) implementation ofMozilla's Parser API. It does not currently support some of Mozilla's extensions, such as generators, list comprehensions,for each, E4X, etc. but may eventually support ones that are, or become Harmony proposals.Builders are also supported.

Parsing really large files can be slow, for reasonsarticulated by Andy Chu.

Download

You can download a minified-standalone version of reflect.js to embed in web pageshere.

Install

Reflect.js is available as a CommonJS module for Node.js. Simply install it with npm:

npm install reflect

Use

var Reflect = require('reflect');var ast = Reflect.parse("var a = 4 + 7");console.log(Reflect.stringify(ast, "  "));

Refer toMozilla's docs for details on the AST interface.

Builders

The optionalbuilder parameter to Reflect.parse() makes it possible to construct user-specified data from the parser, rather than the default Node objects.

The reflect.js module exports thedefault builder so you can redefine only the node constructors you care about and leave the rest default.

var Reflect = require('reflect');var builder = Reflect.builder;// redefine callback for variable declarationsbuilder["variableDeclaration"] = function (kind, declarators, loc) { ... };var ast = Reflect.parse("var a = 4 + 7", {builder: builder});

License

MIT X Licensed.

About

Implementation of Mozilla's Parser API in JavaScript

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp