Saturday 3 June 2017

Using Node.JS statements inside of PEG.js grammar

In my grammar rule i need to check whether directory exists.
However, seems i'm unable to use Node.JS-specific code in grammar JS.
Is it correct? Any workaround?
Thanks and sorry if a question was a silly one :)

Example grammar:

{
    var fs = require('fs');

    function isDirectoryExists(dir) {
        return fs.existsSync(path);
    }
}

Main = "stub"

Output from the PEG.js online playground:

require is not defined



via eraxillan

No comments:

Post a Comment