forked from SiliconEngine/PerlToPHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPpiStatement.php
56 lines (52 loc) · 1.67 KB
/
PpiStatement.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
<?php
/**
* PPI statement nodes.
*
* @author Tim Behrendsen <tim@siliconengine.com>
* @created 2016-10-14
*/
class PpiStatement extends PpiNode
{
public function anaContext()
{
// Use context of parent
$this->setContext($this->parent->context);
}
}
class PpiStatementExpression extends PpiStatement { }
class PpiStatementPackage extends PpiStatement { }
class PpiStatementSub extends PpiStatement { }
class PpiStatementScheduled extends PpiStatementSub { }
class PpiStatementCompound extends PpiStatement { }
class PpiStatementBreak extends PpiStatement { }
class PpiStatementGiven extends PpiStatement { }
class PpiStatementWhen extends PpiStatement { }
class PpiStatementData extends PpiStatement { }
class PpiStatementEnd extends PpiStatement { }
class PpiStatementVariable extends PpiStatementExpression { }
class PpiStatementNull extends PpiStatement { }
class PpiStatementUnmatchedBrace extends PpiStatement { }
class PpiStatementUnknown extends PpiStatement { }
/**
* Label
* Nothing to do except convert some unfortunate names that are reserved
* words in PHP.
*/
class PpiStatementInclude extends PpiStatement
{
function genCode()
{
if (! $this->converted) {
// Comment out warning directives and don't convert it.
$peek = $this->peekAhead(2);
if (in_array($peek[0]->content, ['no', 'use'])
&& $peek[1]->content == 'warnings') {
$peek[0]->content = "//{$peek[0]->content}";
foreach ($this->children as $child) {
$child->converted = true;
}
}
}
return parent::genCode();
}
}