author | Markus Bröker <broeker.markus@googlemail.com> |
Thu, 12 Nov 2015 14:39:16 +0100 | |
changeset 0 | 4869aea77e21 |
permissions | -rw-r--r-- |
0
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
1 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
2 |
* Smarty Internal Plugin Configfileparser |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
3 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
4 |
* This is the config file parser |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
5 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
6 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
7 |
* @package Smarty |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
8 |
* @subpackage Config |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
9 |
* @author Uwe Tews |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
10 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
11 |
%name TPC_ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
12 |
%declare_class { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
13 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
14 |
* Smarty Internal Plugin Configfileparse |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
15 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
16 |
* This is the config file parser. |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
17 |
* It is generated from the smarty_internal_configfileparser.y file |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
18 |
* @package Smarty |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
19 |
* @subpackage Compiler |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
20 |
* @author Uwe Tews |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
21 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
22 |
class Smarty_Internal_Configfileparser |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
23 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
24 |
%include_class |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
25 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
26 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
27 |
* result status |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
28 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
29 |
* @var bool |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
30 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
31 |
public $successful = true; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
32 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
33 |
* return value |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
34 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
35 |
* @var mixed |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
36 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
37 |
public $retvalue = 0; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
38 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
39 |
* @var |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
40 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
41 |
public $yymajor; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
42 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
43 |
* lexer object |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
44 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
45 |
* @var Smarty_Internal_Configfilelexer |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
46 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
47 |
private $lex; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
48 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
49 |
* internal error flag |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
50 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
51 |
* @var bool |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
52 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
53 |
private $internalError = false; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
54 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
55 |
* compiler object |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
56 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
57 |
* @var Smarty_Internal_Config_File_Compiler |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
58 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
59 |
public $compiler = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
60 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
61 |
* smarty object |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
62 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
63 |
* @var Smarty |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
64 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
65 |
public $smarty = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
66 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
67 |
* copy of config_overwrite property |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
68 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
69 |
* @var bool |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
70 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
71 |
private $configOverwrite = false; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
72 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
73 |
* copy of config_read_hidden property |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
74 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
75 |
* @var bool |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
76 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
77 |
private $configReadHidden = false; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
78 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
79 |
* helper map |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
80 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
81 |
* @var array |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
82 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
83 |
private static $escapes_single = Array('\\' => '\\', |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
84 |
'\'' => '\''); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
85 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
86 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
87 |
* constructor |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
88 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
89 |
* @param Smarty_Internal_Configfilelexer $lex |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
90 |
* @param Smarty_Internal_Config_File_Compiler $compiler |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
91 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
92 |
function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
93 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
94 |
// set instance object |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
95 |
self::instance($this); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
96 |
$this->lex = $lex; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
97 |
$this->smarty = $compiler->smarty; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
98 |
$this->compiler = $compiler; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
99 |
$this->configOverwrite = $this->smarty->config_overwrite; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
100 |
$this->configReadHidden = $this->smarty->config_read_hidden; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
101 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
102 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
103 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
104 |
* @param null $new_instance |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
105 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
106 |
* @return null |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
107 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
108 |
public static function &instance($new_instance = null) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
109 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
110 |
static $instance = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
111 |
if (isset($new_instance) && is_object($new_instance)) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
112 |
$instance = $new_instance; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
113 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
114 |
return $instance; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
115 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
116 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
117 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
118 |
* parse optional boolean keywords |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
119 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
120 |
* @param string $str |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
121 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
122 |
* @return bool |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
123 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
124 |
private function parse_bool($str) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
125 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
126 |
$str = strtolower($str); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
127 |
if (in_array($str, array('on', 'yes', 'true'))) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
128 |
$res = true; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
129 |
} else { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
130 |
$res = false; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
131 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
132 |
return $res; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
133 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
134 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
135 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
136 |
* parse single quoted string |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
137 |
* remove outer quotes |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
138 |
* unescape inner quotes |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
139 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
140 |
* @param string $qstr |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
141 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
142 |
* @return string |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
143 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
144 |
private static function parse_single_quoted_string($qstr) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
145 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
146 |
$escaped_string = substr($qstr, 1, strlen($qstr) - 2); //remove outer quotes |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
147 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
148 |
$ss = preg_split('/(\\\\.)/', $escaped_string, - 1, PREG_SPLIT_DELIM_CAPTURE); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
149 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
150 |
$str = ""; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
151 |
foreach ($ss as $s) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
152 |
if (strlen($s) === 2 && $s[0] === '\\') { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
153 |
if (isset(self::$escapes_single[$s[1]])) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
154 |
$s = self::$escapes_single[$s[1]]; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
155 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
156 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
157 |
$str .= $s; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
158 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
159 |
return $str; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
160 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
161 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
162 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
163 |
* parse double quoted string |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
164 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
165 |
* @param string $qstr |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
166 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
167 |
* @return string |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
168 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
169 |
private static function parse_double_quoted_string($qstr) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
170 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
171 |
$inner_str = substr($qstr, 1, strlen($qstr) - 2); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
172 |
return stripcslashes($inner_str); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
173 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
174 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
175 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
176 |
* parse triple quoted string |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
177 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
178 |
* @param string $qstr |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
179 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
180 |
* @return string |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
181 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
182 |
private static function parse_tripple_double_quoted_string($qstr) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
183 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
184 |
return stripcslashes($qstr); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
185 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
186 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
187 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
188 |
* set a config variable in target array |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
189 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
190 |
* @param array $var |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
191 |
* @param array $target_array |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
192 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
193 |
private function set_var(Array $var, Array &$target_array) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
194 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
195 |
$key = $var["key"]; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
196 |
$value = $var["value"]; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
197 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
198 |
if ($this->configOverwrite || !isset($target_array['vars'][$key])) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
199 |
$target_array['vars'][$key] = $value; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
200 |
} else { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
201 |
settype($target_array['vars'][$key], 'array'); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
202 |
$target_array['vars'][$key][] = $value; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
203 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
204 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
205 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
206 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
207 |
* add config variable to global vars |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
208 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
209 |
* @param array $vars |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
210 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
211 |
private function add_global_vars(Array $vars) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
212 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
213 |
if (!isset($this->compiler->config_data['vars'])) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
214 |
$this->compiler->config_data['vars'] = Array(); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
215 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
216 |
foreach ($vars as $var) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
217 |
$this->set_var($var, $this->compiler->config_data); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
218 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
219 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
220 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
221 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
222 |
* add config variable to section |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
223 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
224 |
* @param string $section_name |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
225 |
* @param array $vars |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
226 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
227 |
private function add_section_vars($section_name, Array $vars) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
228 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
229 |
if (!isset($this->compiler->config_data['sections'][$section_name]['vars'])) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
230 |
$this->compiler->config_data['sections'][$section_name]['vars'] = Array(); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
231 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
232 |
foreach ($vars as $var) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
233 |
$this->set_var($var, $this->compiler->config_data['sections'][$section_name]); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
234 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
235 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
236 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
237 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
238 |
%token_prefix TPC_ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
239 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
240 |
%parse_accept |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
241 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
242 |
$this->successful = !$this->internalError; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
243 |
$this->internalError = false; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
244 |
$this->retvalue = $this->_retvalue; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
245 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
246 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
247 |
%syntax_error |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
248 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
249 |
$this->internalError = true; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
250 |
$this->yymajor = $yymajor; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
251 |
$this->compiler->trigger_config_file_error(); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
252 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
253 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
254 |
%stack_overflow |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
255 |
{ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
256 |
$this->internalError = true; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
257 |
$this->compiler->trigger_config_file_error("Stack overflow in configfile parser"); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
258 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
259 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
260 |
// Complete config file |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
261 |
start(res) ::= global_vars sections. { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
262 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
263 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
264 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
265 |
// Global vars |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
266 |
global_vars(res) ::= var_list(vl). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
267 |
$this->add_global_vars(vl); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
268 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
269 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
270 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
271 |
// Sections |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
272 |
sections(res) ::= sections section. { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
273 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
274 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
275 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
276 |
sections(res) ::= . { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
277 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
278 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
279 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
280 |
section(res) ::= OPENB SECTION(i) CLOSEB newline var_list(vars). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
281 |
$this->add_section_vars(i, vars); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
282 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
283 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
284 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
285 |
section(res) ::= OPENB DOT SECTION(i) CLOSEB newline var_list(vars). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
286 |
if ($this->configReadHidden) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
287 |
$this->add_section_vars(i, vars); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
288 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
289 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
290 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
291 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
292 |
// Var list |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
293 |
var_list(res) ::= var_list(vl) newline. { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
294 |
res = vl; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
295 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
296 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
297 |
var_list(res) ::= var_list(vl) var(v). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
298 |
res = array_merge(vl, Array(v)); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
299 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
300 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
301 |
var_list(res) ::= . { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
302 |
res = Array(); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
303 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
304 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
305 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
306 |
// Var |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
307 |
var(res) ::= ID(id) EQUAL value(v). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
308 |
res = Array("key" => id, "value" => v); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
309 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
310 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
311 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
312 |
value(res) ::= FLOAT(i). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
313 |
res = (float) i; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
314 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
315 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
316 |
value(res) ::= INT(i). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
317 |
res = (int) i; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
318 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
319 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
320 |
value(res) ::= BOOL(i). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
321 |
res = $this->parse_bool(i); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
322 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
323 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
324 |
value(res) ::= SINGLE_QUOTED_STRING(i). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
325 |
res = self::parse_single_quoted_string(i); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
326 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
327 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
328 |
value(res) ::= DOUBLE_QUOTED_STRING(i). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
329 |
res = self::parse_double_quoted_string(i); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
330 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
331 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
332 |
value(res) ::= TRIPPLE_QUOTES(i) TRIPPLE_TEXT(c) TRIPPLE_QUOTES_END(ii). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
333 |
res = self::parse_tripple_double_quoted_string(c); |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
334 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
335 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
336 |
value(res) ::= TRIPPLE_QUOTES(i) TRIPPLE_QUOTES_END(ii). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
337 |
res = ''; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
338 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
339 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
340 |
value(res) ::= NAKED_STRING(i). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
341 |
res = i; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
342 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
343 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
344 |
// NOTE: this is not a valid rule |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
345 |
// It is added hier to produce a usefull error message on a missing '='; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
346 |
value(res) ::= OTHER(i). { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
347 |
res = i; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
348 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
349 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
350 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
351 |
// Newline and comments |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
352 |
newline(res) ::= NEWLINE. { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
353 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
354 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
355 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
356 |
newline(res) ::= COMMENTSTART NEWLINE. { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
357 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
358 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
359 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
360 |
newline(res) ::= COMMENTSTART NAKED_STRING NEWLINE. { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
361 |
res = null; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
362 |
} |