Bonjour a tous,

J'ai un conflit décalage / réduction dans mon Yacc, j'aurais besoin de votre aide précieuse.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%{
#include <stdio.h>
static int yyerror(char* s);
%}

%union {
	char* string;  /*String Buffer*/
}

%start programme

%token <string> IDF QSTRING IMG HTMLCODE
%token BO BF PO PF AO AF 
%token VIRG POINT
%token FOR OF WITH

%%


programme:		langage
			| programme langage 
			;

langage:	codeJHP 
			| autrecode
                        ;	
			
codeJHP: 		BO definitions BF
			|codeJHP BO definitions BF
			;
				
definitions: 		variable
			| fonction
			| boucle
			;
				
variable: 		IDF PO QSTRING PF
			;
				
fonction: 		IDF parametre
			;

boucle: 		FOR parametre OF parametre WITH parametre AO contenu AF
			;	

parametre: 		attributs
			| bdd
;

attributs:           PO attri_suite PF
;

attri_suite:         IDF POINT IDF
                        | attri_suite IDF POINT IDF
;

bdd:                  PO IDF param_suite PF
			;
				
param_suite: 	VIRG IDF 
			| param_suite VIRG IDF
			;
								
contenu: 		definitions
			|contenu definitions
			;

autrecode: 		HTMLCODE
			;

%%

int main (int argc, char *argv[]){      
	
	printf("Langage JHP :\n");
	
	yyparse();

	return 0;
}

static int yyerror(char *s){
	printf("\nSYNTAX ERROR !!!\n");
	return 0;
}
Cordialement