📄 gmrdrv.pas
字号:
(* gmrdrv.pas: Please see the end of Draak.pas for copyright information *)
(* This file may NOT be distributed without Draak.pas and is under the same *)
(* licence agreement as Draak.pas. *)
unit gmrdrv;
interface
uses filedrv, sysutils, StrUtils, hashs;
type
PGmr = ^TGmr;
TGmr = class
private
ghash: THash;
goal: PHashNode;
public
constructor init(inF: TFile);
function getHash: THash;
function getGoal: RHashNode;
function getHashNode(s: string; hint: word; count: word): PHashNode;
end;
implementation
constructor TGmr.init(inF: TFile);
var s: string;
posStr: word;
begin
ghash := THash.Create;
goal := nil;
try
while inF.eof <> true do
begin
s := inF.getLine;
if s = '' then continue;
if s[1] = '#' then continue;
{Macros}
if s[1] <> '<' then
begin
ghash.addMacro(s);
continue;
end;
{LHS}
ghash.add(LeftStr(s, AnsiPos('>', s)));
if goal = nil then
goal := ghash.hashLookup(LeftStr(s, AnsiPos('>', s)));
posStr := AnsiPos('->', s)+1;
if s[posStr+1] = ' ' then posStr := posStr+1;
delete(s, 1, posStr);
{RHS}
ghash.addRHS(s);
end;
finally
inF.Destroy;
end;
end;
function TGmr.getHash: THash;
begin
result := ghash;
end;
function TGmr.getGoal: RHashNode;
begin
result := goal^;
end;
function TGmr.getHashNode(s: string; hint: word; count: word): PHashNode;
begin
result := ghash.hashLookup(s, hint, count);
end;
{* So, what does gmrdrv do? Well, it will handle opening a grammer file, *}
{* parsing it into memory, and giving the apporiate rule to those that ask. *}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -