Description

Package parser implements a parser for JavaScript.

import (
    "github.com/robertkrimen/otto/parser"
)

Parse and return an AST

filename := "" // A filename is optional
src := `
    // Sample xyzzy example
    (function(){
        if (3.14159 > 0) {
            console.log("Hello, World.");
            return;
        }

        var xyzzy = NaN;
        console.log("Nothing happens.");
        return xyzzy;
    })();
`

// Parse some JavaScript, yielding a *ast.Program and/or an ErrorList
program, err := parser.ParseFile(nil, filename, src, 0)

Warning

The parser and AST interfaces are still works-in-progress (particularly where node types are concerned) and may change in the future.

parser is referenced in 6 repositories

github.com/robertkrimen/otto github.com/tiborvass/go-jsx github.com/benhinchley/mooove

...