-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFomlParser.php
executable file
·34 lines (31 loc) · 1.2 KB
/
FomlParser.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
<?php
class FomlParser
{
static $NODE_CLASSES = array(
'FomlExecNode',
'FomlEvalNode',
'FomlElementNode',
'FomlCommentNode',
'FomlDoctypeNode',
'FomlFilterNode',
'FomlTextNode' // this must be last because it matches everything
);
static $FILTER_CLASSES = array(
'include' => 'FomlIncludeFilter',
'namespace' => 'FomlNamespaceFilter'
);
// returns a FomlDocument instance
static function ParseFile($FileName, $State=null)
{
$foml = file_get_contents($FileName);
return FomlParser::ParseString($foml, $State);
}
static function ParseString($Foml, $State)
{
$tree = FomlParseTree::Parse($Foml);
$doc = $tree->Generate();
if ($State) $doc->state = $State; // for subdocuments, pass the parent document state along
return $doc->RenderToString(); // returns php code
}
}
?>