diff --git a/scripts/phutil_rebuild_map.php b/scripts/phutil_rebuild_map.php index bd9a6621..865f30dc 100755 --- a/scripts/phutil_rebuild_map.php +++ b/scripts/phutil_rebuild_map.php @@ -230,8 +230,18 @@ final class PhutilLibraryMapBuilder { $this->log("Analyzing {$count} files with {$limit} subprocesses...\n"); foreach (Futures($futures)->limit($limit) as $file => $future) { + $result = $future->resolveJSON(); + if (empty($result['error'])) { + $symbol_map[$file] = $result; + } else { + echo phutil_console_format( + "\n**SYNTAX ERROR!**\nFile: %s\nLine: %d\n\n%s\n", + Filesystem::readablePath($result['file']), + $result['line'], + $result['error']); + exit(1); + } $this->log("."); - $symbol_map[$file] = $future->resolveJSON(); } $this->log("\nDone.\n"); } diff --git a/scripts/phutil_symbols.php b/scripts/phutil_symbols.php index 8e1b2229..28253596 100755 --- a/scripts/phutil_symbols.php +++ b/scripts/phutil_symbols.php @@ -75,7 +75,20 @@ $path = Filesystem::resolvePath(head($paths)); $show_all = $args->getArg('all'); $source_code = Filesystem::readFile($path); -$tree = XHPASTTree::newFromData($source_code); + +try { + $tree = XHPASTTree::newFromData($source_code); +} catch (XHPASTSyntaxErrorException $ex) { + $result = array( + 'error' => $ex->getMessage(), + 'line' => $ex->getErrorLine(), + 'file' => $path, + ); + $json = new PhutilJSON(); + echo $json->encodeFormatted($result); + exit(0); +} + $root = $tree->getRootNode(); $root->buildSelectCache();