Example #1
0
 public function execute($args)
 {
     array_shift($args);
     // Remove the script name
     if (count($args) >= 2) {
         $name = ucfirst($args[1]);
         foreach (Clips\config('peg_dir') as $peg_dir) {
             $file = Clips\try_path(Clips\path_join($peg_dir, $name . '.peg'));
             if ($file) {
                 break;
             }
         }
         if (!$file) {
             $this->error('No peg file found ');
             return;
         } else {
             $args[1] = $file;
         }
         foreach (Clips\config('library_dir') as $lib_dir) {
             $out_dir = Clips\try_path($lib_dir);
             if ($out_dir) {
                 break;
             }
         }
         if ($out_dir) {
             $out = Clips\path_join($out_dir, $name . '.php');
             $args[2] = $out;
             $this->output('Writing file %s.', $out);
         }
     }
     Compiler::cli($args);
 }
Example #2
0
<?php

require 'autoloader.php';
use hafriedlander\Peg\Compiler;
Compiler::cli($_SERVER['argv']);
Example #3
0
<?php

/*                                                                        *
 * This file is part of the ToDate library                                *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License, either version 3   *
 * of the License, or (at your option) any later version.                 *
 *                                                                        *
 * (c) 2012-2014 Johannes Künsebeck <kuensebeck@googlemail.com            */
use hafriedlander\Peg\Compiler;
require_once __DIR__ . '/../vendor/hafriedlander/php-peg/autoloader.php';
$input = file_get_contents(__DIR__ . '/FormalDateExpressionParser.peg.inc');
$output = Compiler::compile($input);
file_put_contents(__DIR__ . '/../src/ToDate/Parser/Generated/FormalDateExpressionParser.php', $output);