資源簡介
php實現的文法分析
代例子可供學習《編譯原理》時做實驗
代碼片段和文件信息
header(‘Content-type:?text/html;charset=GBK‘);
include?‘ttrie.php‘;
class?Rule?extends?TTrie?{
??public?$rule?=?array();
??public?$savematch?=?0;
??function?__construct($s=‘‘)?{
$this->set(?array(
‘?‘?=>?‘Separated‘
“\r\n“?=>?‘set_rule‘
“\n“?=>?‘set_rule‘
“\t“?=>?‘Separated‘
‘->‘?=>?‘Separated‘
‘→‘?=>?‘Separated‘
‘|‘?=>?‘set_parallel_rule‘
));
$this->match($s);
if($this->rule[0][0]?==?$this->rule[0][1])?{
if(count($this->rule[0])?==?2)?$this->rule[0][0]?.=?“‘“;
else?array_unshift($this->rule?array($this->rule[0][0].“‘“?$this->rule[0][0]));
}else?{
$c?=?$this->rule[0][0];
$n?=?0;
foreach($this->rule?as?$r)?if($r[0]?==?$c)?$n++;
if($n?>?1)?array_unshift($this->rule?array($this->rule[0][0].“‘“?$this->rule[0][0]));
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????93??2012-08-25?18:03??3.txt
?????文件????????142??2012-08-25?15:04??4.txt
?????文件?????????70??2012-08-26?11:37??5.txt
?????文件?????????82??2012-08-25?17:36??6.txt
?????文件?????????82??2012-08-25?19:09??7.txt
?????文件????????152??2012-08-27?15:25??8.txt
?????文件??????13940??2012-08-27?16:27??Grammar.php
?????文件???????2133??2012-08-21?13:06??TTrie.php
?????文件????????113??2012-08-25?17:56??1.txt
?????文件????????121??2012-08-25?11:27??2.txt
-----------?---------??----------?-----??----
????????????????16928????????????????????10
- 上一篇:100多個經典簡單PHP代碼
- 下一篇:php簡單新聞發布管理
評論
共有 條評論