How to use the php-parser.parseCode function in php-parser

To help you get started, we’ve selected a few php-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HvyIndustries / crane / client / src / hvy / treeBuilder.ts View on Github external
return new Promise((resolve, reject) =>
        {
            phpParser.parser.locations = true;
            phpParser.parser.docBlocks = true;
            var ast = phpParser.parseCode(text);

            this.BuildObjectTree(ast, filePath).then((tree) =>
            {
                // TODO -- Convert this to promise
                var symbolCache = this.BuildSymbolCache(tree, filePath);

                var returnObj = {
                    tree: tree,
                    symbolCache: symbolCache
                };

                // DEBUG
                console.log("Built tree for file: " + filePath);

                resolve(returnObj);
            });
github chris-l / php-unparser / test / index.js View on Github external
fs.readFile(filename, function(err, data) {
    if (!err) {
      counter ++;
      try {
        var ast = parser.parseCode(data.toString(), {
          parser: {
            extractDoc: true,
            debug: isDebug
          },
          ast: {
            withPositions: true
          }
        });
        var code = unparse(ast);
        if (isDebug) console.log(code);
        if (counter === total) {
          console.log('Finished to test ' + total + ' file(s)');
          process.exit(0);
        }
        if (counter % 500 === 0) {
          console.log(counter + ' of ' + total + ' - ' + Math.round(counter / total * 100) + '%');
github glayzzle / php-writer / src / index.js View on Github external
var Writer = function(buffer, options = {}) {
  this.options = Object.assign({}, defaultOptions, options);
  this.ast = parser.parseCode(buffer, this.options);
};
editor(Writer, 1);
github glayzzle / php-transpiler / index.html View on Github external
function refreshOutput() {
			try {
				var ast = parser.parseCode(
					editor.getValue(), {
						ast: {
							withPositions: true
						},
						parser: {
							extractDoc: true
						}
					}, 'browser input'
				);
				var code = transpiler.generate(ast, {}, 'browser input');
				$('#error-msg').hide();
				$('#output').show();
				output.setValue(code);
				output.setReadOnly(true);
			} catch(e) {
				$('#error-msg').show();

php-parser

Parse PHP code from JS and returns its AST

BSD-3-Clause
Latest version published 11 months ago

Package Health Score

75 / 100
Full package analysis