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

(* global definitions: *)
uses lexlib;
	Type
		Classes = (recherche, article, nom, pronom, verbe, adjectif,
		conjonction, preposition) ;
		MotCl = record
				mot : string ;
				classe : Classes
			end ;
	Const Max = 100 ;
	Var 	mode : Classes ;
		table : array[1..Max] of MotCl ;
		ltable : integer ;

	procedure ranger(c : Classes ; m : string) ;
	var i : integer ;
	begin
	i := 1 ;
	while (i <= ltable) and ((c <> table[i].classe) or (m <>table[i].mot)) do
		i := i+1 ;
	if i > ltable then begin ltable := ltable + 1 ;
				table[ltable].classe := c ;
				table[ltable].mot := m 
			end 
	end ;

	procedure rechercher(m : string) ;
	var 	i : integer ;
		trouve : boolean ;
	begin
	i := 1 ;
	trouve := false ;
	write(m, ' : ') ;
	while (i <= ltable)  do begin
				if m = table[i].mot then begin
					case table[i].classe of
						article : writeln('article');
						nom : writeln('nom') ;
						pronom : writeln('pronom') ;
						verbe : writeln('verbe') ;
						adjectif : writeln('adjectif') ;
						conjonction: writeln('conjonction') ;
						preposition : writeln('preposition')
					end ;
					trouve := true
					end ;
				i := i+1 
				end ;
	if (not trouve) then write('inconnu') ;
	writeln 
	end ;



function yylex : Integer;

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


begin
  (* actions: *)
  case yyruleno of
  1:
         	mode := article ;
  2:
     		mode := nom ;
  3:
        	mode := pronom ;
  4:
       		mode := verbe ;
  5:
          	mode := adjectif ;
  6:
             	mode := conjonction ;
  7:
             	mode := preposition ;


  8:
   		mode := recherche ;

  9:
        if mode = recherche then rechercher( yytext)
	else ranger(mode, yytext) ;

  10:
 	;

  end;
end(*yyaction*);

(* DFA table: *)

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

const

yynmarks   = 65;
yynmatches = 65;
yyntrans   = 104;
yynstates  = 54;

yyk : array [1..yynmarks] of Integer = (
  { 0: }
  { 1: }
  { 2: }
  8,
  { 3: }
  9,
  10,
  { 4: }
  10,
  { 5: }
  9,
  10,
  { 6: }
  9,
  10,
  { 7: }
  9,
  10,
  { 8: }
  9,
  10,
  { 9: }
  9,
  10,
  { 10: }
  9,
  { 11: }
  9,
  { 12: }
  9,
  { 13: }
  9,
  { 14: }
  9,
  { 15: }
  9,
  { 16: }
  9,
  { 17: }
  9,
  { 18: }
  9,
  { 19: }
  2,
  9,
  { 20: }
  9,
  { 21: }
  9,
  { 22: }
  9,
  { 23: }
  9,
  { 24: }
  9,
  { 25: }
  9,
  { 26: }
  9,
  { 27: }
  9,
  { 28: }
  9,
  { 29: }
  9,
  { 30: }
  9,
  { 31: }
  9,
  { 32: }
  9,
  { 33: }
  9,
  { 34: }
  4,
  9,
  { 35: }
  9,
  { 36: }
  9,
  { 37: }
  9,
  { 38: }
  3,
  9,
  { 39: }
  9,
  { 40: }
  9,
  { 41: }
  1,
  9,
  { 42: }
  9,
  { 43: }
  9,
  { 44: }
  9,
  { 45: }
  5,
  9,
  { 46: }
  9,
  { 47: }
  9,
  { 48: }
  9,
  { 49: }
  9,
  { 50: }
  9,
  { 51: }
  9,
  { 52: }
  7,
  9,
  { 53: }
  6,
  9
);

yym : array [1..yynmatches] of Integer = (
{ 0: }
{ 1: }
{ 2: }
  8,
{ 3: }
  9,
  10,
{ 4: }
  10,
{ 5: }
  9,
  10,
{ 6: }
  9,
  10,
{ 7: }
  9,
  10,
{ 8: }
  9,
  10,
{ 9: }
  9,
  10,
{ 10: }
  9,
{ 11: }
  9,
{ 12: }
  9,
{ 13: }
  9,
{ 14: }
  9,
{ 15: }
  9,
{ 16: }
  9,
{ 17: }
  9,
{ 18: }
  9,
{ 19: }
  2,
  9,
{ 20: }
  9,
{ 21: }
  9,
{ 22: }
  9,
{ 23: }
  9,
{ 24: }
  9,
{ 25: }
  9,
{ 26: }
  9,
{ 27: }
  9,
{ 28: }
  9,
{ 29: }
  9,
{ 30: }
  9,
{ 31: }
  9,
{ 32: }
  9,
{ 33: }
  9,
{ 34: }
  4,
  9,
{ 35: }
  9,
{ 36: }
  9,
{ 37: }
  9,
{ 38: }
  3,
  9,
{ 39: }
  9,
{ 40: }
  9,
{ 41: }
  1,
  9,
{ 42: }
  9,
{ 43: }
  9,
{ 44: }
  9,
{ 45: }
  5,
  9,
{ 46: }
  9,
{ 47: }
  9,
{ 48: }
  9,
{ 49: }
  9,
{ 50: }
  9,
{ 51: }
  9,
{ 52: }
  7,
  9,
{ 53: }
  6,
  9
);

yyt : array [1..yyntrans] of YYTrec = (
{ 0: }
  ( cc: [ #1..#9,#11..'`','{'..#255 ]; s: 4),
  ( cc: [ #10 ]; s: 2),
  ( cc: [ 'a'..'z' ]; s: 3),
{ 1: }
  ( cc: [ #1..#9,#11..'`','{'..#255 ]; s: 4),
  ( cc: [ #10 ]; s: 2),
  ( cc: [ 'a' ]; s: 5),
  ( cc: [ 'b','d'..'m','o','q'..'u','w'..'z' ]; s: 3),
  ( cc: [ 'c' ]; s: 9),
  ( cc: [ 'n' ]; s: 6),
  ( cc: [ 'p' ]; s: 7),
  ( cc: [ 'v' ]; s: 8),
{ 2: }
{ 3: }
  ( cc: [ 'a'..'z' ]; s: 10),
{ 4: }
{ 5: }
  ( cc: [ 'a'..'c','e'..'q','s'..'z' ]; s: 10),
  ( cc: [ 'd' ]; s: 12),
  ( cc: [ 'r' ]; s: 11),
{ 6: }
  ( cc: [ 'a'..'n','p'..'z' ]; s: 10),
  ( cc: [ 'o' ]; s: 13),
{ 7: }
  ( cc: [ 'a'..'q','s'..'z' ]; s: 10),
  ( cc: [ 'r' ]; s: 14),
{ 8: }
  ( cc: [ 'a'..'d','f'..'z' ]; s: 10),
  ( cc: [ 'e' ]; s: 15),
{ 9: }
  ( cc: [ 'a'..'n','p'..'z' ]; s: 10),
  ( cc: [ 'o' ]; s: 16),
{ 10: }
  ( cc: [ 'a'..'z' ]; s: 10),
{ 11: }
  ( cc: [ 'a'..'s','u'..'z' ]; s: 10),
  ( cc: [ 't' ]; s: 17),
{ 12: }
  ( cc: [ 'a'..'i','k'..'z' ]; s: 10),
  ( cc: [ 'j' ]; s: 18),
{ 13: }
  ( cc: [ 'a'..'l','n'..'z' ]; s: 10),
  ( cc: [ 'm' ]; s: 19),
{ 14: }
  ( cc: [ 'a'..'d','f'..'n','p'..'z' ]; s: 10),
  ( cc: [ 'e' ]; s: 21),
  ( cc: [ 'o' ]; s: 20),
{ 15: }
  ( cc: [ 'a'..'q','s'..'z' ]; s: 10),
  ( cc: [ 'r' ]; s: 22),
{ 16: }
  ( cc: [ 'a'..'m','o'..'z' ]; s: 10),
  ( cc: [ 'n' ]; s: 23),
{ 17: }
  ( cc: [ 'a'..'h','j'..'z' ]; s: 10),
  ( cc: [ 'i' ]; s: 24),
{ 18: }
  ( cc: [ 'a'..'d','f'..'z' ]; s: 10),
  ( cc: [ 'e' ]; s: 25),
{ 19: }
  ( cc: [ 'a'..'z' ]; s: 10),
{ 20: }
  ( cc: [ 'a'..'m','o'..'z' ]; s: 10),
  ( cc: [ 'n' ]; s: 26),
{ 21: }
  ( cc: [ 'a'..'o','q'..'z' ]; s: 10),
  ( cc: [ 'p' ]; s: 27),
{ 22: }
  ( cc: [ 'a','c'..'z' ]; s: 10),
  ( cc: [ 'b' ]; s: 28),
{ 23: }
  ( cc: [ 'a'..'i','k'..'z' ]; s: 10),
  ( cc: [ 'j' ]; s: 29),
{ 24: }
  ( cc: [ 'a','b','d'..'z' ]; s: 10),
  ( cc: [ 'c' ]; s: 30),
{ 25: }
  ( cc: [ 'a','b','d'..'z' ]; s: 10),
  ( cc: [ 'c' ]; s: 31),
{ 26: }
  ( cc: [ 'a'..'n','p'..'z' ]; s: 10),
  ( cc: [ 'o' ]; s: 32),
{ 27: }
  ( cc: [ 'a'..'n','p'..'z' ]; s: 10),
  ( cc: [ 'o' ]; s: 33),
{ 28: }
  ( cc: [ 'a'..'d','f'..'z' ]; s: 10),
  ( cc: [ 'e' ]; s: 34),
{ 29: }
  ( cc: [ 'a'..'n','p'..'z' ]; s: 10),
  ( cc: [ 'o' ]; s: 35),
{ 30: }
  ( cc: [ 'a'..'k','m'..'z' ]; s: 10),
  ( cc: [ 'l' ]; s: 36),
{ 31: }
  ( cc: [ 'a'..'s','u'..'z' ]; s: 10),
  ( cc: [ 't' ]; s: 37),
{ 32: }
  ( cc: [ 'a'..'l','n'..'z' ]; s: 10),
  ( cc: [ 'm' ]; s: 38),
{ 33: }
  ( cc: [ 'a'..'r','t'..'z' ]; s: 10),
  ( cc: [ 's' ]; s: 39),
{ 34: }
  ( cc: [ 'a'..'z' ]; s: 10),
{ 35: }
  ( cc: [ 'a'..'m','o'..'z' ]; s: 10),
  ( cc: [ 'n' ]; s: 40),
{ 36: }
  ( cc: [ 'a'..'d','f'..'z' ]; s: 10),
  ( cc: [ 'e' ]; s: 41),
{ 37: }
  ( cc: [ 'a'..'h','j'..'z' ]; s: 10),
  ( cc: [ 'i' ]; s: 42),
{ 38: }
  ( cc: [ 'a'..'z' ]; s: 10),
{ 39: }
  ( cc: [ 'a'..'h','j'..'z' ]; s: 10),
  ( cc: [ 'i' ]; s: 43),
{ 40: }
  ( cc: [ 'a','b','d'..'z' ]; s: 10),
  ( cc: [ 'c' ]; s: 44),
{ 41: }
  ( cc: [ 'a'..'z' ]; s: 10),
{ 42: }
  ( cc: [ 'a'..'e','g'..'z' ]; s: 10),
  ( cc: [ 'f' ]; s: 45),
{ 43: }
  ( cc: [ 'a'..'s','u'..'z' ]; s: 10),
  ( cc: [ 't' ]; s: 46),
{ 44: }
  ( cc: [ 'a'..'s','u'..'z' ]; s: 10),
  ( cc: [ 't' ]; s: 47),
{ 45: }
  ( cc: [ 'a'..'z' ]; s: 10),
{ 46: }
  ( cc: [ 'a'..'h','j'..'z' ]; s: 10),
  ( cc: [ 'i' ]; s: 48),
{ 47: }
  ( cc: [ 'a'..'h','j'..'z' ]; s: 10),
  ( cc: [ 'i' ]; s: 49),
{ 48: }
  ( cc: [ 'a'..'n','p'..'z' ]; s: 10),
  ( cc: [ 'o' ]; s: 50),
{ 49: }
  ( cc: [ 'a'..'n','p'..'z' ]; s: 10),
  ( cc: [ 'o' ]; s: 51),
{ 50: }
  ( cc: [ 'a'..'m','o'..'z' ]; s: 10),
  ( cc: [ 'n' ]; s: 52),
{ 51: }
  ( cc: [ 'a'..'m','o'..'z' ]; s: 10),
  ( cc: [ 'n' ]; s: 53),
{ 52: }
  ( cc: [ 'a'..'z' ]; s: 10),
{ 53: }
  ( cc: [ 'a'..'z' ]; s: 10)
);

yykl : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 1,
{ 2: } 1,
{ 3: } 2,
{ 4: } 4,
{ 5: } 5,
{ 6: } 7,
{ 7: } 9,
{ 8: } 11,
{ 9: } 13,
{ 10: } 15,
{ 11: } 16,
{ 12: } 17,
{ 13: } 18,
{ 14: } 19,
{ 15: } 20,
{ 16: } 21,
{ 17: } 22,
{ 18: } 23,
{ 19: } 24,
{ 20: } 26,
{ 21: } 27,
{ 22: } 28,
{ 23: } 29,
{ 24: } 30,
{ 25: } 31,
{ 26: } 32,
{ 27: } 33,
{ 28: } 34,
{ 29: } 35,
{ 30: } 36,
{ 31: } 37,
{ 32: } 38,
{ 33: } 39,
{ 34: } 40,
{ 35: } 42,
{ 36: } 43,
{ 37: } 44,
{ 38: } 45,
{ 39: } 47,
{ 40: } 48,
{ 41: } 49,
{ 42: } 51,
{ 43: } 52,
{ 44: } 53,
{ 45: } 54,
{ 46: } 56,
{ 47: } 57,
{ 48: } 58,
{ 49: } 59,
{ 50: } 60,
{ 51: } 61,
{ 52: } 62,
{ 53: } 64
);

yykh : array [0..yynstates-1] of Integer = (
{ 0: } 0,
{ 1: } 0,
{ 2: } 1,
{ 3: } 3,
{ 4: } 4,
{ 5: } 6,
{ 6: } 8,
{ 7: } 10,
{ 8: } 12,
{ 9: } 14,
{ 10: } 15,
{ 11: } 16,
{ 12: } 17,
{ 13: } 18,
{ 14: } 19,
{ 15: } 20,
{ 16: } 21,
{ 17: } 22,
{ 18: } 23,
{ 19: } 25,
{ 20: } 26,
{ 21: } 27,
{ 22: } 28,
{ 23: } 29,
{ 24: } 30,
{ 25: } 31,
{ 26: } 32,
{ 27: } 33,
{ 28: } 34,
{ 29: } 35,
{ 30: } 36,
{ 31: } 37,
{ 32: } 38,
{ 33: } 39,
{ 34: } 41,
{ 35: } 42,
{ 36: } 43,
{ 37: } 44,
{ 38: } 46,
{ 39: } 47,
{ 40: } 48,
{ 41: } 50,
{ 42: } 51,
{ 43: } 52,
{ 44: } 53,
{ 45: } 55,
{ 46: } 56,
{ 47: } 57,
{ 48: } 58,
{ 49: } 59,
{ 50: } 60,
{ 51: } 61,
{ 52: } 63,
{ 53: } 65
);

yyml : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 1,
{ 2: } 1,
{ 3: } 2,
{ 4: } 4,
{ 5: } 5,
{ 6: } 7,
{ 7: } 9,
{ 8: } 11,
{ 9: } 13,
{ 10: } 15,
{ 11: } 16,
{ 12: } 17,
{ 13: } 18,
{ 14: } 19,
{ 15: } 20,
{ 16: } 21,
{ 17: } 22,
{ 18: } 23,
{ 19: } 24,
{ 20: } 26,
{ 21: } 27,
{ 22: } 28,
{ 23: } 29,
{ 24: } 30,
{ 25: } 31,
{ 26: } 32,
{ 27: } 33,
{ 28: } 34,
{ 29: } 35,
{ 30: } 36,
{ 31: } 37,
{ 32: } 38,
{ 33: } 39,
{ 34: } 40,
{ 35: } 42,
{ 36: } 43,
{ 37: } 44,
{ 38: } 45,
{ 39: } 47,
{ 40: } 48,
{ 41: } 49,
{ 42: } 51,
{ 43: } 52,
{ 44: } 53,
{ 45: } 54,
{ 46: } 56,
{ 47: } 57,
{ 48: } 58,
{ 49: } 59,
{ 50: } 60,
{ 51: } 61,
{ 52: } 62,
{ 53: } 64
);

yymh : array [0..yynstates-1] of Integer = (
{ 0: } 0,
{ 1: } 0,
{ 2: } 1,
{ 3: } 3,
{ 4: } 4,
{ 5: } 6,
{ 6: } 8,
{ 7: } 10,
{ 8: } 12,
{ 9: } 14,
{ 10: } 15,
{ 11: } 16,
{ 12: } 17,
{ 13: } 18,
{ 14: } 19,
{ 15: } 20,
{ 16: } 21,
{ 17: } 22,
{ 18: } 23,
{ 19: } 25,
{ 20: } 26,
{ 21: } 27,
{ 22: } 28,
{ 23: } 29,
{ 24: } 30,
{ 25: } 31,
{ 26: } 32,
{ 27: } 33,
{ 28: } 34,
{ 29: } 35,
{ 30: } 36,
{ 31: } 37,
{ 32: } 38,
{ 33: } 39,
{ 34: } 41,
{ 35: } 42,
{ 36: } 43,
{ 37: } 44,
{ 38: } 46,
{ 39: } 47,
{ 40: } 48,
{ 41: } 50,
{ 42: } 51,
{ 43: } 52,
{ 44: } 53,
{ 45: } 55,
{ 46: } 56,
{ 47: } 57,
{ 48: } 58,
{ 49: } 59,
{ 50: } 60,
{ 51: } 61,
{ 52: } 63,
{ 53: } 65
);

yytl : array [0..yynstates-1] of Integer = (
{ 0: } 1,
{ 1: } 4,
{ 2: } 12,
{ 3: } 12,
{ 4: } 13,
{ 5: } 13,
{ 6: } 16,
{ 7: } 18,
{ 8: } 20,
{ 9: } 22,
{ 10: } 24,
{ 11: } 25,
{ 12: } 27,
{ 13: } 29,
{ 14: } 31,
{ 15: } 34,
{ 16: } 36,
{ 17: } 38,
{ 18: } 40,
{ 19: } 42,
{ 20: } 43,
{ 21: } 45,
{ 22: } 47,
{ 23: } 49,
{ 24: } 51,
{ 25: } 53,
{ 26: } 55,
{ 27: } 57,
{ 28: } 59,
{ 29: } 61,
{ 30: } 63,
{ 31: } 65,
{ 32: } 67,
{ 33: } 69,
{ 34: } 71,
{ 35: } 72,
{ 36: } 74,
{ 37: } 76,
{ 38: } 78,
{ 39: } 79,
{ 40: } 81,
{ 41: } 83,
{ 42: } 84,
{ 43: } 86,
{ 44: } 88,
{ 45: } 90,
{ 46: } 91,
{ 47: } 93,
{ 48: } 95,
{ 49: } 97,
{ 50: } 99,
{ 51: } 101,
{ 52: } 103,
{ 53: } 104
);

yyth : array [0..yynstates-1] of Integer = (
{ 0: } 3,
{ 1: } 11,
{ 2: } 11,
{ 3: } 12,
{ 4: } 12,
{ 5: } 15,
{ 6: } 17,
{ 7: } 19,
{ 8: } 21,
{ 9: } 23,
{ 10: } 24,
{ 11: } 26,
{ 12: } 28,
{ 13: } 30,
{ 14: } 33,
{ 15: } 35,
{ 16: } 37,
{ 17: } 39,
{ 18: } 41,
{ 19: } 42,
{ 20: } 44,
{ 21: } 46,
{ 22: } 48,
{ 23: } 50,
{ 24: } 52,
{ 25: } 54,
{ 26: } 56,
{ 27: } 58,
{ 28: } 60,
{ 29: } 62,
{ 30: } 64,
{ 31: } 66,
{ 32: } 68,
{ 33: } 70,
{ 34: } 71,
{ 35: } 73,
{ 36: } 75,
{ 37: } 77,
{ 38: } 78,
{ 39: } 80,
{ 40: } 82,
{ 41: } 83,
{ 42: } 85,
{ 43: } 87,
{ 44: } 89,
{ 45: } 90,
{ 46: } 92,
{ 47: } 94,
{ 48: } 96,
{ 49: } 98,
{ 50: } 100,
{ 51: } 102,
{ 52: } 103,
{ 53: } 104
);


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*);


begin
		ltable := 0 ;
		mode := recherche ;
                writeln('Tapez "nom toto" pour declarer toto comme un nom');
                writeln('Tapez "verbe toter" pour declarer toter comme un verbe etc');
                writeln('Etc. Ensuite vous pouvez taper une phrase pour l''analyser');
                writeln('Ctrl-C pour quitter');
                yylex
end.


