GithubHelp home page GithubHelp logo

sbassett29 / peast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mck89/peast

0.0 0.0 0.0 1.68 MB

JavaScript parser written in PHP that generates AST from your code according to ECMAScript specification

License: BSD 3-Clause "New" or "Revised" License

JavaScript 2.92% PHP 97.08%

peast's Introduction

Peast

Latest Stable Version Total Downloads License Build Status

Peast (PHP ECMAScript Abstract Syntax Tree) is a PHP 5.4+ library that parses JavaScript code, according to ECMAScript specification, and generates an abstract syntax tree following the ESTree standard.

Installation

Include the following requirement to your composer.json:

{
	"require": {
		"mck89/peast": "dev-master"
	}
}

Run composer install to install the package.

Then in your script include the autoloader and you can start using Peast:

require_once "vendor/autoload.php";

$source = "var a = 1"; //Your JavaScript code
$ast = Peast\Peast::latest($source, $options)->parse(); //Parse it!

Known issues

When Xdebug is enabled and Peast is used to scan code that contains deeply nested functions, this fatal error can appear:

PHP Fatal error:  Maximum function nesting level of '512' reached, aborting!

or

PHP Warning:  Uncaught Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames

To prevent this you can set xdebug.max_nesting_level to a higher value, such as 512.

Documentation

Read the documentation for more examples and explanations:

  1. AST generation and tokenization
  2. Tree Traversing
  3. Querying By Selector
  4. Rendering

Changelog

peast's People

Contributors

exussum12 avatar jrfnl avatar krizalys avatar malte-christian avatar mck89 avatar schlessera avatar seka19 avatar soullivaneuh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.