All Projects → estools → Escope

estools / Escope

Licence: bsd-2-clause
Escope: ECMAScript scope analyzer

Programming Languages

javascript
184084 projects - #8 most used programming language
ecmascript
72 projects

Labels

Projects that are alternatives of or similar to Escope

Ratel Core
High performance JavaScript to JavaScript compiler with a Rust core
Stars: ✭ 367 (-26.16%)
Mutual labels:  ast
Rector
Instant Upgrades and Automated Refactoring of any PHP 5.3+ code
Stars: ✭ 4,739 (+853.52%)
Mutual labels:  ast
Unist
Universal Syntax Tree used by @unifiedjs
Stars: ✭ 438 (-11.87%)
Mutual labels:  ast
Node Dependency Tree
Get the dependency tree of a module
Stars: ✭ 383 (-22.94%)
Mutual labels:  ast
Php Parser
🌿 NodeJS PHP Parser - extract AST or tokens (PHP5 and PHP7)
Stars: ✭ 400 (-19.52%)
Mutual labels:  ast
Elm Analyse
A tool that allows you to analyse your Elm code, identify deficiencies and apply best practices.
Stars: ✭ 418 (-15.9%)
Mutual labels:  ast
Hast
Hypertext Abstract Syntax Tree format
Stars: ✭ 344 (-30.78%)
Mutual labels:  ast
Tenko
An 100% spec compliant ES2021 JavaScript parser written in JS
Stars: ✭ 490 (-1.41%)
Mutual labels:  ast
Remark
remark is a popular tool that transforms markdown with plugins. These plugins can inspect and change your markup. You can use remark on the server, the client, CLIs, deno, etc.
Stars: ✭ 4,746 (+854.93%)
Mutual labels:  ast
Tiny Compiler
A tiny compiler for a language featuring LL(2) with Lexer, Parser, ASM-like codegen and VM. Complex enough to give you a flavour of how the "real" thing works whilst not being a mere toy example
Stars: ✭ 425 (-14.49%)
Mutual labels:  ast
Detective
Find all calls to require() no matter how deeply nested using a proper walk of the AST
Stars: ✭ 387 (-22.13%)
Mutual labels:  ast
Astexplorer
A web tool to explore the ASTs generated by various parsers.
Stars: ✭ 4,330 (+771.23%)
Mutual labels:  ast
Cst
🌿 JavaScript Concrete Syntax Tree
Stars: ✭ 417 (-16.1%)
Mutual labels:  ast
Javaparser
Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13
Stars: ✭ 3,972 (+699.2%)
Mutual labels:  ast
Qone
Next-generation web query language, extend .NET LINQ for javascript.
Stars: ✭ 463 (-6.84%)
Mutual labels:  ast
Solhint
Solhint is an open source project created by https://protofire.io. Its goal is to provide a linting utility for Solidity code.
Stars: ✭ 363 (-26.96%)
Mutual labels:  ast
Orgajs
parse org-mode content into AST
Stars: ✭ 417 (-16.1%)
Mutual labels:  ast
Mdast
Markdown Abstract Syntax Tree format
Stars: ✭ 493 (-0.8%)
Mutual labels:  ast
Fantomas
FSharp source code formatter
Stars: ✭ 475 (-4.43%)
Mutual labels:  ast
Debundle
🗃 A javascript debundler. Takes a Browserify or Webpack bundle and recreates the initial, pre-bundled source.
Stars: ✭ 420 (-15.49%)
Mutual labels:  ast

Escope (escope) is ECMAScript scope analyzer extracted from esmangle project.

Build Status

Example

var escope = require('escope');
var esprima = require('esprima');
var estraverse = require('estraverse');

var ast = esprima.parse(code);
var scopeManager = escope.analyze(ast);

var currentScope = scopeManager.acquire(ast);   // global scope

estraverse.traverse(ast, {
    enter: function(node, parent) {
        // do stuff
        
        if (/Function/.test(node.type)) {
            currentScope = scopeManager.acquire(node);  // get current function scope
        }
    },
    leave: function(node, parent) {
        if (/Function/.test(node.type)) {
            currentScope = currentScope.upper;  // set to parent scope
        }
        
        // do stuff
    }
});

Document

Generated JSDoc is here.

Demos and Tools

Demonstration is here by Sasha Mazurov (twitter: @mazurov). issue

Demo

And there are tools constructed on Escope.

License

Copyright (C) 2012-2013 Yusuke Suzuki (twitter: @Constellation) and other contributors.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].