📄 ezscryacc.cod
字号:
(* Yacc parser template (TP Yacc V3.0), V1.2 6-17-91 AG *)
(* global definitions: *)
%%
// function yylex : Integer; forward; // addition 1
function TEzScrParser.yyparse : Integer; // addition 2
var yystate, yysp, yyn : SmallInt;
yys : array [1..yymaxdepth] of SmallInt;
yyv : array [1..yymaxdepth] of YYSType;
yyval : YYSType;
TickStart: DWORD;
Msg: TMsg;
procedure yyaction ( yyruleno : Integer );
(* local definitions: *)
%%
var i: Integer;
gstyle: TEzTableBorderStyle;
fnt: TEzFontStyle;
begin
(* actions: *)
case yyruleno of
%%
end;
end(*yyaction*);
(* parse table: *)
%%
const _error = 256; (* error token *)
function yyact(state, sym : Integer; var act : SmallInt) : Boolean;
(* search action table *)
var k : Integer;
begin
k := yyal[state];
while (k<=yyah[state]) and (yya[k].sym<>sym) do inc(k);
if k>yyah[state] then
yyact := false
else
begin
act := yya[k].act;
yyact := true;
end;
end(*yyact*);
function yygoto(state, sym : Integer; var nstate : SmallInt) : Boolean;
(* search goto table *)
var k : Integer;
begin
k := yygl[state];
while (k<=yygh[state]) and (yyg[k].sym<>sym) do inc(k);
if k>yygh[state] then
yygoto := false
else
begin
nstate := yyg[k].act;
yygoto := true;
end;
end(*yygoto*);
label parse, next, error, errlab, shift, reduce, accept, abort;
begin(*yyparse*)
(* load arrays from resource *)
LoadResArrays;
(* Initialize the tick counter *)
TickStart := GetTickCount;
yystate := 0; yychar := -1; yynerrs := 0; yyerrflag := 0; yysp := 0;
{$ifdef yydebug}
yydebug := true;
{$else}
yydebug := false;
{$endif}
parse:
(* push state and value: *)
inc(yysp);
if yysp>yymaxdepth then
begin
yyerror('yyparse stack overflow');
goto abort;
end;
yys[yysp] := yystate; yyv[yysp] := yyval;
next:
if (yyd[yystate]=0) and (yychar=-1) then
(* get next symbol *)
begin
repeat
yychar := yyLexer.yylex; if yychar<0 then yychar := 0;
// ignore comments and blanks [ \n\t]
if not( (yychar=_COMMENT) or (yychar=_BLANK) or
(yychar=_TAB) or (yychar=_NEWLINE) ) then break;
// check for time elapsed in order to be able to cancel parsing
if GetTickCount>=TickStart+500 then // 1/2 second the test
begin
// check if specific messages are waiting and if so, cancel internal selecting
PeekMessage(Msg, FDrawBox.Handle, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
if (Msg.Message=WM_KEYDOWN) and (Msg.WParam=VK_ESCAPE) then begin
yyerrormsg:= Sscrcanceled;
goto Abort;
end;
TickStart:= GetTickCount;
end;
until false;
if yychar= _ILLEGAL then goto error;
end;
{if yydebug then
writeln( yyLexer.yyOutput, 'state '+intToStr( yystate)+ ', char '+
intToStr( yychar) + ' at line n
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -