Skip to content

Esprima .NET (BSD license) is a .NET port of the esprima.org project. It is a standard-compliant ECMAScript parser (also popularly known as JavaScript).

License

Notifications You must be signed in to change notification settings

atifaziz/esprima-dotnet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status NuGet

Esprima .NET (BSD license) is a .NET port of the esprima.org project. It is a standard-compliant ECMAScript parser (also popularly known as JavaScript).

Features

API

Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) of a JavaScript program.

A simple C# example:

var parser = new JavaScriptParser("const answer = 42");
var program = parser.ParseProgram();

Will return this when serialized in json:

{
    "type": "Program",
    "body": [
        {
            "type": "VariableDeclaration",
            "declarations": [
                {
                    "type": "VariableDeclarator",
                    "id": {
                        "type": "Identifier",
                        "name": "answer"
                    },
                    "init": {
                        "type": "Literal",
                        "value": 42,
                        "raw": "42"
                    }
                }
            ],
            "kind": "const"
        }
    ],
    "sourceType": "script"
}

Benchmarks

Here is a list of common JavaScript libraries and the time it takes to parse them, compared to the time it took for the same script using the original Esprima in Chrome.

Script Size Esprima .NET Esprima (Chrome)
underscore-1.5.2 43 KB 2.4 ms 3.1 ms
backbone-1.1.0 60 KB 2.9 ms 3.5 ms
mootools-1.4.5 163 KB 18.7 ms 16.2 ms
jquery-1.9.1 271 KB 22.8 ms 19.0 ms
yui-3.12.0 341 KB 17.2 ms 16.2 ms
jquery.mobile-1.4.2 456 K 43.3 ms 46.9 ms
angular-1.2.5 721 KB 29.3 ms 37.2 ms

About

Esprima .NET (BSD license) is a .NET port of the esprima.org project. It is a standard-compliant ECMAScript parser (also popularly known as JavaScript).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 93.5%
  • JavaScript 6.5%