Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 29 lines (22 sloc) 0.723 kB
ce8305f @tobiastom Initial implementation (possibly very unstable).
authored
1 <?php
2
3 ini_set('display_errors', 1 );
4 ini_set('memory_limit', -1 );
5 error_reporting(E_ALL);
6
7 require_once __DIR__ . '/Library/PHPParser/bootstrap.php';
8 require_once __DIR__ . '/Classes/ChocolatSerializer.php';
9
10
11 try {
12 if ( !isset( $argv[ 1 ] ) ) {
13 throw new Exception( 'Missing file parameter' );
14 }
15
16 $file = $argv[ 1 ];
17 if ( !file_exists( $file ) ) {
18 throw new Exception( 'Cannot open file: ' . $file );
19 }
20
21 $parser = new PHPParser_Parser( new PHPParser_Lexer );
22 $statements = $parser->parse( file_get_contents( $file ) );
23
24 $serializer = new ChocolatSerializer( file( $file ) );
25 print $serializer->serialize( $statements );
26 } catch( Exception $exception ) {
27 print $exception;
28 die( $exception->getCode() );
29 }
Something went wrong with that request. Please try again.