Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generate the namespace of the parser object (specified by the moduleName) #283

Open
sammyhk opened this issue May 5, 2015 · 0 comments

Comments

@sammyhk
Copy link

sammyhk commented May 5, 2015

As titled.
Now it is not generate the namespace, so we need to prepare the namespace object somewhere else before including the generated parser script, request to generate the namespace object. The generated code should be:

  • module name without namespace (i.e. moduleName = "myParser"):
var myParser = (function () { // same as before
})();
  • module name with single level namespace (i.e. moduleName = "jison.myParser"):
var jison;
(function (jison) {
    jison.myParser = (function () { // same as before
    })();
})(jison || (jison = {})); // only create new object if not exists
  • module name with nested namespace (i.e. moduleName = "com.zaach.jison.myParser"):
var com;
(function (com) {
    var zaach;
    (function (zaach) {
        var jison;
        (function (jison) {
            jison.myParser = (function () { // same as before
            })();
        })(jison = zaach.jison || (zaach.jison = {}));
    })(zaach = com.zaach || (com.zaach = {}));
})(com || (com = {}));
sammyhk added a commit to sammyhk/jison that referenced this issue May 5, 2015
…enerate namespace for the generated parser object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant