-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.php
75 lines (58 loc) · 2.02 KB
/
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Main start point for the PHP Extensions Generator
*
* @author Jefferson González
* @license MIT
* @link http://github.com/wxphp/peg Source code.
*/
// Set the path to peg files by using environment variables if available,
// if not, it uses current path
if(isset($_SERVER["PEG_SKELETON_PATH"]))
define("PEG_SKELETON_PATH", $_SERVER["PEG_SKELETON_PATH"]);
else
define("PEG_SKELETON_PATH", "./skeleton");
if(isset($_SERVER["PEG_LIBRARY_PATH"]))
define("PEG_LIBRARY_PATH", $_SERVER["PEG_LIBRARY_PATH"]);
else
define("PEG_LIBRARY_PATH", "./");
if(isset($_SERVER["PEG_LOCALE_PATH"]))
define("PEG_LOCALE_PATH", $_SERVER["PEG_LOCALE_PATH"]);
else
define("PEG_LOCALE_PATH", "./locale");
if(!file_exists(PEG_LIBRARY_PATH . "lib"))
throw new Exception("Peg lib path not found.");
if(!file_exists(PEG_SKELETON_PATH))
throw new Exception("Peg skeleton files path not found.");
// Register class auto-loader
function peg_autoloader($class_name)
{
$file = str_replace("\\", "/", $class_name) . ".php";
include(PEG_LIBRARY_PATH . "lib/" . strtolower($file));
}
spl_autoload_register("peg_autoloader");
// Register global function for translating and to facilitate automatic
// generation of po files.
function t($text)
{
static $language_object;
if(!$language_object)
{
$language_object = new Localization\Language(PEG_LOCALE_PATH);
}
return $language_object->Translate($text);
}
// Initialize the application
Peg\Application::Initialize();
// Retrieve a reference of main command line parser
$parser = Peg\Application::GetParser();
// Set Application details
$parser->application_name = "peg";
$parser->application_version = "1.0";
$parser->application_description = t("PHP Extension Generator (http://github.com/wxphp/peg)");
// Register command operations
$parser->RegisterCommand(Peg\Application::GetHelpCommand());
$parser->RegisterCommand(Peg\Application::GetInitCommand());
$parser->RegisterCommand(Peg\Application::GetParseCommand());
$parser->Start($argc, $argv);
?>