mirror of
https://github.com/danog/parser.git
synced 2025-01-23 05:21:22 +01:00
27 lines
687 B
PHP
Executable File
27 lines
687 B
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
use Trunk\Compiler;
|
|
use Trunk\Parser;
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
require_once __DIR__ . '/../src/bindgen.php';
|
|
|
|
$file = $argv[1];
|
|
$program = Parser::the()->parse($file);
|
|
$compiled = (new Compiler)->compile($program);
|
|
|
|
// dd($compiled);
|
|
|
|
$cwd = getcwd();
|
|
if (! is_dir(__DIR__ . '/../build')) {
|
|
mkdir(__DIR__ . '/../build');
|
|
}
|
|
chdir(__DIR__ . '/../build');
|
|
if (file_exists('./go.mod')) {
|
|
unlink('./go.mod');
|
|
}
|
|
shell_exec('go mod init my-script');
|
|
shell_exec('go get github.com/ryangjchandler/trunk');
|
|
shell_exec('go mod edit -replace github.com/ryangjchandler/trunk=../../trunk_go');
|
|
file_put_contents('./my-script.go', $compiled); |