
(* lexical analyzer template (TP Lex V3.0), V1.0 3-2-91 AG *)

(* global definitions: *)

  (* Lexical analyzer for the sample Yacc program in Tp4.y. *)



function yylex : Integer;

procedure yyaction ( yyruleno : Integer );
  (* local definitions: *)


begin
  (* actions: *)
  case yyruleno of
  1:
    	begin
         yylval.yyInteger:=yyleng;
	 return(NUM)
	end;

  2:
                		;
  3,
  4:
  				returnc(yytext[1]);
  end;
end(*yyaction*);

(* DFA table: *)

type YYTRec = record
                cc : set of Char;
                s  : Integer;
              end;

const

yynmarks   = 7;
yynmatches = 7;
yyntrans   = 10;
yynstates  = 7;

yyk : array [1..yynmarks] of Integer = (
  { 0: }
  { 1: }
  { 2: }
  1,
  3,
  { 3: }
  2,
  3,
  { 4: }
  3,
  { 5: }
  4,
  { 6: }
  1
);

yym : array [1..yynmatches] of Integer = (
{ 0: }
{ 1: }
{ 2: }
  1,
  3,
{ 3: }
  2,
  3,
{ 4: }
  3,
{ 5: }
  4,
{ 6: }
  1
);

yyt : array [1..yyntrans] of YYTrec = (
{ 0: }
  ( cc: [ #1..#9,#11..#31,'!'..'0','2'..#255 ]; s: 4),
  ( cc: [ #10 ]; s: 5),
  ( cc: [ ' ' ]; s: 3),
  ( cc: [ '1' ]; s: 2),
{ 1: }
  ( cc: [ #1..#9,#11..#31,'!'..'0','2'..#255 ]; s: 4),
  ( cc: [ #10 ]; s: 5),
  ( cc: [ ' ' ]; s: 3),
  ( cc: [ '1' ]; s: 2),
{ 2: }
  ( cc: [ '1' ]; s: 6),
{ 3: }
{ 4: }
{ 5: }
{ 6: }
  ( cc: [ '1' ]; s: 6)
);

yykl : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 1,
{ 2: } 1,
{ 3: } 3,
{ 4: } 5,
{ 5: } 6,
{ 6: } 7
);

yykh : array [0..yynstates-1] of Integer = (
{ 0: } 0,
{ 1: } 0,
{ 2: } 2,
{ 3: } 4,
{ 4: } 5,
{ 5: } 6,
{ 6: } 7
);

yyml : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 1,
{ 2: } 1,
{ 3: } 3,
{ 4: } 5,
{ 5: } 6,
{ 6: } 7
);

yymh : array [0..yynstates-1] of Integer = (
{ 0: } 0,
{ 1: } 0,
{ 2: } 2,
{ 3: } 4,
{ 4: } 5,
{ 5: } 6,
{ 6: } 7
);

yytl : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 5,
{ 2: } 9,
{ 3: } 10,
{ 4: } 10,
{ 5: } 10,
{ 6: } 10
);

yyth : array [0..yynstates-1] of Integer = (
{ 0: } 4,
{ 1: } 8,
{ 2: } 9,
{ 3: } 9,
{ 4: } 9,
{ 5: } 9,
{ 6: } 10
);


var yyn : Integer;

label start, scan, action;

begin

start:

  (* initialize: *)

  yynew;

scan:

  (* mark positions and matches: *)

  for yyn := yykl[yystate] to     yykh[yystate] do yymark(yyk[yyn]);
  for yyn := yymh[yystate] downto yyml[yystate] do yymatch(yym[yyn]);

  if yytl[yystate]>yyth[yystate] then goto action; (* dead state *)

  (* get next character: *)

  yyscan;

  (* determine action: *)

  yyn := yytl[yystate];
  while (yyn<=yyth[yystate]) and not (yyactchar in yyt[yyn].cc) do inc(yyn);
  if yyn>yyth[yystate] then goto action;
    (* no transition on yyactchar in this state *)

  (* switch to new state: *)

  yystate := yyt[yyn].s;

  goto scan;

action:

  (* execute action: *)

  if yyfind(yyrule) then
    begin
      yyaction(yyrule);
      if yyreject then goto action;
    end
  else if not yydefault and yywrap then
    begin
      yyclear;
      return(0);
    end;

  if not yydone then goto start;

  yylex := yyretval;

end(*yylex*);

