Skip to content

Commit

Permalink
Merge branch '1.0.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ichiriac committed Dec 27, 2016
2 parents 06d9107 + 2775844 commit 1a27f8d
Show file tree
Hide file tree
Showing 87 changed files with 6,056 additions and 1,012 deletions.
10 changes: 5 additions & 5 deletions bin/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function runWrite(size) {
result.push(
duration('Array init time', hrTime)
);

diff = hd.end();
result.push(diff.after.size_bytes - diff.before.size_bytes);

Expand Down Expand Up @@ -70,14 +70,14 @@ function runRead(size) {
{type: 'class', name: 'foo', meta: []}
];
var ok = false;
var hrTime = process.hrtime();
var hrTime = process.hrtime();
for(var i = 0; i < size; i++) {
ok = arr[0][0] === 'class' && arr[0][1] === 'foo';
}
result.push(
duration('Array read time', hrTime)
);
hrTime = process.hrtime();
hrTime = process.hrtime();
for(var i = 0; i < size; i++) {
ok = obj[0].type === 'class' && arr[0].name === 'foo';
}
Expand Down Expand Up @@ -152,7 +152,7 @@ function consumeTokens(engine, files) {
}
}
var hrend = process.hrtime(hrstart);
diff = hd.end();
diff = hd.end();
var duration = (hrend[0] * 1000000 * 1000) + hrend[1];
console.log('Tokens extracted :', tSize);
console.log('Tokens by sec (x1000) :', (Math.round((tSize / (duration / 1000000 / 1000)) / 100) / 10));
Expand Down Expand Up @@ -180,7 +180,7 @@ function compareResults(a, b) {
// parsing tests
if (typeof global.gc === 'function') global.gc();
console.log('\n--- parsing files - actual lexer version :');
var engine = require('../main');
var engine = require('../src/index');
engine.lexer.asp_tags = true;
engine.lexer.short_tags = true;
var actual = consumeTokens(engine, files);
Expand Down
44 changes: 44 additions & 0 deletions bin/formats/ast.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* Copyright (C) 2016 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
ini_set('memory_limit', '1024M');
$start = microtime(true);
if (is_file($argv[1])) {
$ast = ast\parse_file($argv[1], 40);
} else {
$ast = ast\parse_code($argv[1], 40);
}
// serialize nodes to associative arrays
function getNode($node) {
if (!$node) return false;
if (is_array($node)) {
$result = array();
foreach($node as $item) $result[] = getNode($item);
return $result;
}
if (!is_object($node)) {
return $node;
}
$result = array(
'kind' => ast\get_kind_name($node->kind),
'lineno' => $node->lineno
);
if ($node->flags > 0) {
$result['flags'] = ast\kind_uses_flags($node->flags);
}
if ($node instanceof ast\Node\Decl) {
$result['endLineno'] = $node->endLineno;
$result['name'] = $node->name;
$result['docComment'] = getNode($node->docComment);
}
if ($node->children) {
$result['children'] = getNode($node->children);
}
return $result;
}

echo json_encode( getNode($ast) );
2 changes: 1 addition & 1 deletion bin/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var util = require('util');
var fs = require('fs');
var path = require('path');

var engine = require('../main');
var engine = require('../src/index');
engine = new engine();

engine.lexer.short_tags = true;
Expand Down
Loading

0 comments on commit 1a27f8d

Please sign in to comment.