Classe avec l’implémentation des actionsclass ActionsLex
inherit BASIC_ROUTINES ConstLex ActionsG
redefine Initactions, Action, ActionFinale, ActionNonfinale
end;
feature -- variables utilisees par les actions semantiques
unite : UniteLex;
categorie : INTEGER;
valeur : STRING;
heures,duree : INTEGER;
feature
InitActions is -- Initialisation des variables de calcul
do
valeur := "";
categorie := LexErreur;
duree := 0;
end ;
-- Actions semantiques
Action (I : INTEGER; Tete:INTEGER) is
do
inspect I
when 0 then -- 0 est l'action par defaut : rien
when 1 then heures := tete - ('0').code;
when 2 then heures := heures*10 + tete - ('0').code;
when 3 then duree := duree + heures*60;
when 4 then duree := duree + (tete - ('0').code)*10;
when 5 then duree := duree + tete - ('0').code;
when 6 then categorie:= LexDuree;valeur := duree.out;
when 7 then valeur.extend(charconv(tete));
when 8 then categorie:=LexIdent;valeur.extend(charconv(tete));
when 9 then categorie:= LexSep;valeur:="pt";
when 10 then categorie:= LexSep;valeur:="rc";
end ; --inspect
end ; --action
ActionFinale (E : INTEGER) is
do
if ((categorie = Lexident) and
(valeur.is_equal("plus") or valeur.is_equal("moins") or valeur.is_equal("double")))
then categorie := LexRes end --if
!!unite.make_unite(categorie,valeur)
end ;
ActionNonFinale (E : INTEGER) is
do
ActionFinale(E);
end ; -- actionnonfinale
end --class |