version 1.37, 2012/01/05 10:18:58
|
version 1.49, 2012/09/29 17:53:02
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.5 |
RPL/2 (R) version 4.1.10 |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
Line 364 analyse_syntaxique(struct_processus *s_e
|
Line 364 analyse_syntaxique(struct_processus *s_e
|
enum t_condition { AN_IF = 1, AN_IFERR, AN_THEN, AN_ELSE, AN_ELSEIF, |
enum t_condition { AN_IF = 1, AN_IFERR, AN_THEN, AN_ELSE, AN_ELSEIF, |
AN_END, AN_DO, AN_UNTIL, AN_WHILE, AN_REPEAT, AN_SELECT, |
AN_END, AN_DO, AN_UNTIL, AN_WHILE, AN_REPEAT, AN_SELECT, |
AN_CASE, AN_DEFAULT, AN_UP, AN_DOWN, AN_FOR, AN_START, |
AN_CASE, AN_DEFAULT, AN_UP, AN_DOWN, AN_FOR, AN_START, |
AN_NEXT, AN_STEP }; |
AN_NEXT, AN_STEP, AN_CRITICAL, AN_FORALL }; |
|
|
unsigned char *instruction; |
unsigned char *instruction; |
unsigned char registre; |
unsigned char registre; |
Line 514 analyse_syntaxique(struct_processus *s_e
|
Line 514 analyse_syntaxique(struct_processus *s_e
|
|
|
l_base_pile = l_nouvelle_base_pile; |
l_base_pile = l_nouvelle_base_pile; |
} |
} |
|
else if (strcmp(instruction, "CRITICAL") == 0) |
|
{ |
|
if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile, |
|
AN_CRITICAL)) == NULL) |
|
{ |
|
liberation_analyse(l_base_pile); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
l_base_pile = l_nouvelle_base_pile; |
|
} |
else if (strcmp(instruction, "THEN") == 0) |
else if (strcmp(instruction, "THEN") == 0) |
{ |
{ |
if ((test_analyse(l_base_pile, AN_IF) == d_faux) && |
if ((test_analyse(l_base_pile, AN_IF) == d_faux) && |
Line 572 analyse_syntaxique(struct_processus *s_e
|
Line 585 analyse_syntaxique(struct_processus *s_e
|
(test_analyse(l_base_pile, AN_DEFAULT) == d_faux) && |
(test_analyse(l_base_pile, AN_DEFAULT) == d_faux) && |
(test_analyse(l_base_pile, AN_SELECT) == d_faux) && |
(test_analyse(l_base_pile, AN_SELECT) == d_faux) && |
(test_analyse(l_base_pile, AN_THEN) == d_faux) && |
(test_analyse(l_base_pile, AN_THEN) == d_faux) && |
|
(test_analyse(l_base_pile, AN_CRITICAL) == d_faux) && |
(test_analyse(l_base_pile, AN_ELSE) == d_faux)) |
(test_analyse(l_base_pile, AN_ELSE) == d_faux)) |
{ |
{ |
liberation_analyse(l_base_pile); |
liberation_analyse(l_base_pile); |
Line 753 analyse_syntaxique(struct_processus *s_e
|
Line 767 analyse_syntaxique(struct_processus *s_e
|
|
|
l_base_pile = l_nouvelle_base_pile; |
l_base_pile = l_nouvelle_base_pile; |
} |
} |
|
else if (strcmp(instruction, "FORALL") == 0) |
|
{ |
|
if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile, |
|
AN_FORALL)) == NULL) |
|
{ |
|
liberation_analyse(l_base_pile); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
l_base_pile = l_nouvelle_base_pile; |
|
} |
else if (strcmp(instruction, "NEXT") == 0) |
else if (strcmp(instruction, "NEXT") == 0) |
{ |
{ |
if ((test_analyse(l_base_pile, AN_FOR) == d_faux) && |
if ((test_analyse(l_base_pile, AN_FOR) == d_faux) && |
|
(test_analyse(l_base_pile, AN_FORALL) == d_faux) && |
(test_analyse(l_base_pile, AN_START) == d_faux)) |
(test_analyse(l_base_pile, AN_START) == d_faux)) |
{ |
{ |
liberation_analyse(l_base_pile); |
liberation_analyse(l_base_pile); |
Line 809 analyse_syntaxique(struct_processus *s_e
|
Line 837 analyse_syntaxique(struct_processus *s_e
|
} |
} |
|
|
|
|
|
/* |
|
================================================================================ |
|
Procédure de d'analyse syntaxique du source pour readline |
|
================================================================================ |
|
Entrées : |
|
-------------------------------------------------------------------------------- |
|
Sorties : |
|
- rl_done à 0 ou à 1. |
|
-------------------------------------------------------------------------------- |
|
Effets de bord : |
|
================================================================================ |
|
*/ |
|
|
|
static char *ligne = NULL; |
|
static unsigned int niveau = 0; |
|
|
|
int |
|
readline_analyse_syntaxique(int count, int key) |
|
{ |
|
char prompt[] = "+ %03d> "; |
|
char prompt2[8]; |
|
char *registre; |
|
|
|
struct_processus s_etat_processus; |
|
|
|
if ((*rl_line_buffer) == d_code_fin_chaine) |
|
{ |
|
if (ligne == NULL) |
|
{ |
|
rl_done = 1; |
|
} |
|
else |
|
{ |
|
rl_done = 0; |
|
} |
|
} |
|
else |
|
{ |
|
if (ligne == NULL) |
|
{ |
|
if ((ligne = malloc((strlen(rl_line_buffer) + 1) |
|
* sizeof(char))) == NULL) |
|
{ |
|
rl_done = 1; |
|
return(0); |
|
} |
|
|
|
strcpy(ligne, rl_line_buffer); |
|
} |
|
else |
|
{ |
|
registre = ligne; |
|
|
|
if ((ligne = malloc((strlen(registre) |
|
+ strlen(rl_line_buffer) + 2) * sizeof(char))) == NULL) |
|
{ |
|
rl_done = 1; |
|
return(0); |
|
} |
|
|
|
sprintf(ligne, "%s %s", registre, rl_line_buffer); |
|
} |
|
|
|
rl_replace_line("", 1); |
|
|
|
s_etat_processus.definitions_chainees = ligne; |
|
s_etat_processus.debug = d_faux; |
|
s_etat_processus.erreur_systeme = d_es; |
|
s_etat_processus.erreur_execution = d_ex; |
|
|
|
if (analyse_syntaxique(&s_etat_processus) == d_absence_erreur) |
|
{ |
|
rl_done = 1; |
|
} |
|
else |
|
{ |
|
if (s_etat_processus.erreur_systeme != d_es) |
|
{ |
|
rl_done = 1; |
|
} |
|
else |
|
{ |
|
rl_done = 0; |
|
rl_crlf(); |
|
|
|
sprintf(prompt2, prompt, ++niveau); |
|
|
|
rl_expand_prompt(prompt2); |
|
rl_on_new_line(); |
|
} |
|
} |
|
} |
|
|
|
if (rl_done != 0) |
|
{ |
|
uprintf("\n"); |
|
|
|
if (ligne != NULL) |
|
{ |
|
rl_replace_line(ligne, 1); |
|
|
|
free(ligne); |
|
ligne = NULL; |
|
} |
|
|
|
niveau = 0; |
|
} |
|
|
|
return(0); |
|
} |
|
|
|
int |
|
readline_effacement(int count, int key) |
|
{ |
|
rl_done = 0; |
|
rl_replace_line("", 1); |
|
|
|
free(ligne); |
|
ligne = NULL; |
|
niveau = 0; |
|
|
|
uprintf("^G\n"); |
|
rl_expand_prompt("RPL/2> "); |
|
rl_on_new_line(); |
|
return(0); |
|
} |
|
|
|
|
/* |
/* |
================================================================================ |
================================================================================ |
Routine d'échange de deux variables |
Routine d'échange de deux variables |