jscc-parser
Version:
A LALR(1) Parser Generator for JavaScript written in JavaScript.
282 lines (244 loc) • 12.2 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: io/ioNode.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: io/ioNode.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/*
* Universal module definition for the Node version of the io module.
*/
(function(root, factory) {
/* istanbul ignore next */
if (typeof define === 'function' && define.amd) {
define(['require', '../global'], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require);
} else {
root.jsccio = factory(function(mod) {
return root["jscc" + mod.split("/").pop()];
});
}
}(this,
/**
* @param {reqParameter} require
* @param {...*} others
* @returns {jscc.io}
*/
function(require, others) {
//>>excludeStart("closure", pragmas.closure);
var jscc = {};
//>>excludeEnd("closure");
var global = require("../global"), thisUtil, thisFs, thisPath;
//>>excludeStart("amdclean", pragmas.amdclean);
/*
//>>excludeEnd("amdclean");
thisUtil = util;
thisFs = fs;
thisPath = path;
//>>excludeStart("amdclean", pragmas.amdclean);
*/
thisUtil = require('util');
thisFs = require('fs');
thisPath = require('path');
//>>excludeEnd("amdclean");
/**
* @constructor
* @implements {jscc.io}
*/
jscc.ioNode = function() {
};
/**
* @inheritDoc
*/
jscc.ioNode.prototype.read_all_input = function(options) {
var filename = "";
var async = false;
/**
* @param {string} chunk
* @param {string=} encoding
* @param {Function=} next
*/
var chunkCallback = function(chunk, encoding, next) {
};
var endCallback = function() {
};
if (options) {
if (typeof options === "string") {
filename = options;
} else if (typeof options === "function") {
// amdclean
chunkCallback = /** @type {function(string)} */ (options);
async = true;
} else if (typeof options === "object") {
if (typeof options.filename === "string") {
filename = options.filename;
}
if (typeof options.chunkCallback === "function") {
chunkCallback = options.chunkCallback;
async = true;
}
if (typeof options.endCallback === "function") {
endCallback = options.endCallback;
async = true;
}
}
}
if (filename !== "" && !thisPath.isAbsolute(filename)) {
filename = thisPath.join(process.cwd(), filename);
}
if (filename !== "" && !async) {
return thisFs.readFileSync(filename, "utf-8");
}
if (filename === "" && !async) {
/**
* @type {string}
*/
var result = "";
var done = false;
process.stdin.setEncoding("utf-8");
process.stdin.on('end', function() {
done = true;
});
process.stdin.on('data', function(chunk, encoding, next) {
result += "" + chunk;
next();
});
while (!done) {
}
return /** @type {string} */ (result);
}
if (filename !== "") {
thisFs.readFile(filename, "utf-8", chunkCallback);
} else {
process.stdin.setEncoding("utf-8");
process.stdin.on("end", endCallback);
process.stdin.on("data", chunkCallback);
}
};
/**
* @inheritDoc
*/
jscc.ioNode.prototype.read_template = function(options) {
var filename = null;
var async = false;
/**
* @param {string} chunk
* @param {string=} encoding
* @param {Function=} next
*/
var chunkCallback = function(chunk, encoding, next) {
};
if (options) {
if (typeof options === "string") {
filename = options;
} else if (typeof options === "function") {
chunkCallback = options.chunkCallback;
async = true;
} else if (typeof options === "object") {
if (typeof options.filename === "string") {
filename = options.filename;
}
if (typeof options.chunkCallback === "function") {
chunkCallback = options.chunkCallback;
async = true;
}
}
}
if (filename === null) {
if (async) {
chunkCallback(global.DEFAULT_DRIVER, "utf-8", function() {
});
} else {
return global.DEFAULT_DRIVER;
}
} else {
if (!thisPath.isAbsolute(filename)) {
filename = thisPath.join(process.cwd(), filename);
}
if (!async) {
return thisFs.readFileSync(filename, "utf-8");
}
thisFs.readFile(filename, "utf-8", chunkCallback);
}
};
/**
* @inheritDoc
*/
jscc.ioNode.prototype.write_output = function(options) {
var text = "";
var destination = "";
var async = false;
var callback = function() {
};
if (options) {
if (typeof options === "string") {
text = options;
} else if (typeof options === "object") {
if (typeof options.text === "string") {
text = options.text;
}
if (typeof options.destination === "string") {
destination = options.destination;
}
if (typeof options.callback === "function") {
callback = options.callback;
async = true;
}
}
}
if (destination !== "" && !async) {
thisFs.writeFileSync(destination, text, "utf-8");
} else if (destination === "" && !async) {
process.stdout.write(text, "utf-8");
} else if (destination !== "") {
thisFs.writeFile(destination, text, "utf-8", callback);
} else {
process.stdout.on('finish', callback);
process.stdout.write(text, "utf-8");
process.stdout.end();
}
};
/**
* @inheritDoc
*/
jscc.ioNode.prototype.write_debug = function(text) {
thisUtil.puts(text);
};
/**
* @inheritDoc
*/
jscc.ioNode.prototype.exit = function(exitCode) {
process.exit(exitCode);
};
/**
* @module jscc/io/io
*/
return new jscc.ioNode();
}));
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-jscc.html">jscc</a></li><li><a href="module-jscc_bitset_BitSet32.html">jscc/bitset/BitSet32</a></li><li><a href="module-jscc_bitset_BitSetBool.html">jscc/bitset/BitSetBool</a></li><li><a href="module-jscc_bitset_BitSetJava.html">jscc/bitset/BitSetJava</a></li><li><a href="module-jscc_classes_Dfa.html">jscc/classes/Dfa</a></li><li><a href="module-jscc_classes_Item.html">jscc/classes/Item</a></li><li><a href="module-jscc_classes_Nfa.html">jscc/classes/Nfa</a></li><li><a href="module-jscc_classes_Param.html">jscc/classes/Param</a></li><li><a href="module-jscc_classes_Production.html">jscc/classes/Production</a></li><li><a href="module-jscc_classes_State.html">jscc/classes/State</a></li><li><a href="module-jscc_classes_Symbol.html">jscc/classes/Symbol</a></li><li><a href="module-jscc_classes_TableEntry.html">jscc/classes/TableEntry</a></li><li><a href="module-jscc_enums_ASSOC.html">jscc/enums/ASSOC</a></li><li><a href="module-jscc_enums_EDGE.html">jscc/enums/EDGE</a></li><li><a href="module-jscc_enums_EXEC.html">jscc/enums/EXEC</a></li><li><a href="module-jscc_enums_LOG_LEVEL.html">jscc/enums/LOG_LEVEL</a></li><li><a href="module-jscc_enums_MODE_GEN.html">jscc/enums/MODE_GEN</a></li><li><a href="module-jscc_enums_SPECIAL.html">jscc/enums/SPECIAL</a></li><li><a href="module-jscc_enums_SYM.html">jscc/enums/SYM</a></li><li><a href="module-jscc_first.html">jscc/first</a></li><li><a href="module-jscc_global.html">jscc/global</a></li><li><a href="module-jscc_integrity.html">jscc/integrity</a></li><li><a href="module-jscc_io_io.html">jscc/io/io</a></li><li><a href="module-jscc_lexdbg.html">jscc/lexdbg</a></li><li><a href="module-jscc_lexdfa.html">jscc/lexdfa</a></li><li><a href="module-jscc_log_log.html">jscc/log/log</a></li><li><a href="module-jscc_parse.html">jscc/parse</a></li><li><a href="module-jscc_printtab.html">jscc/printtab</a></li><li><a href="module-jscc_regex.html">jscc/regex</a></li><li><a href="module-jscc_util.html">jscc/util</a></li></ul><h3>Classes</h3><ul><li><a href="-_anonymous_-jscc.BitSet32.html">BitSet32</a></li><li><a href="-_anonymous_-jscc.BitSetBool.html">BitSetBool</a></li><li><a href="-_anonymous_-jscc.BitSetJava.html">BitSetJava</a></li><li><a href="-_anonymous_-jscc.classes.Dfa.html">classes.Dfa</a></li><li><a href="-_anonymous_-jscc.first.html">first</a></li><li><a href="-_anonymous_-jscc.global.html">global</a></li><li><a href="-_anonymous_-jscc.integrity.html">integrity</a></li><li><a href="-_anonymous_-jscc.ioBrowser.html">ioBrowser</a></li><li><a href="-_anonymous_-jscc.ioNashorn.html">ioNashorn</a></li><li><a href="-_anonymous_-jscc.ioNode.html">ioNode</a></li><li><a href="-_anonymous_-jscc.ioRhino.html">ioRhino</a></li><li><a href="-_anonymous_-jscc.lexdbg.html">lexdbg</a></li><li><a href="-_anonymous_-jscc.lexdfa.html">lexdfa</a></li><li><a href="-_anonymous_-jscc.logBrowser.html">logBrowser</a></li><li><a href="-_anonymous_-jscc.logJava.html">logJava</a></li><li><a href="-_anonymous_-jscc.logNode.html">logNode</a></li><li><a href="-_anonymous_-jscc.printtab.html">printtab</a></li><li><a href="-_anonymous_-jscc.util.html">util</a></li><li><a href="jscc_debug.html">jscc/debug</a></li><li><a href="jscc_nfaStates.html">jscc/nfaStates</a></li><li><a href="jscc_tabgen.html">jscc/tabgen</a></li><li><a href="%257Bjscc.classes%257D.jscc.classes.State.html">jscc.classes.State</a></li></ul><h3>Namespaces</h3><ul><li><a href="jscc.debug.html">debug</a></li></ul><h3>Interfaces</h3><ul><li><a href="jscc.bitset.html">bitset</a></li><li><a href="jscc.io.html">io</a></li><li><a href="jscc.log.html">log</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Aug 01 2016 11:09:19 GMT-0500 (Central Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>