blob: 5cae2f88343e42136c689a4703e2c687ddcbe4f7 (
plain)
| 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 | 
%{
#include "tokens.h"
/* Affiche un message d'erreur suite à l'analyse en échec. */
static int yyerror(operands_format *, char *);
%}
%code requires {
#include "decl.h"
}
%union {
    char *string;                           /* Chaîne de caractères        */
}
%define api.pure full
%parse-param { operands_format *format }
%code provides {
#define YY_DECL \
    int format_lex(YYSTYPE *yylvalp)
YY_DECL;
}
%token OPS_TYPE OR
%type <string> OPS_TYPE
%%
types : type
      | type OR types
type : OPS_TYPE { add_operands_format_type(format, $1); }
%%
/******************************************************************************
*                                                                             *
*  Paramètres  : format = structure impliquée dans le processus.              *
*                msg    = message d'erreur.                                   *
*                                                                             *
*  Description : Affiche un message d'erreur suite à l'analyse en échec.      *
*                                                                             *
*  Retour      : 0                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/
static int yyerror(operands_format *format, char *msg)
{
	printf("bits yyerror line %d: %s\n", yyget_lineno(), msg);
	return 0;
}
/******************************************************************************
*                                                                             *
*  Paramètres  : format = structure à constituer à partir de données lues.    *
*                raw    = données brutes à analyser.                          *
*                                                                             *
*  Description : Interprête des données relatives à une définition de format. *
*                                                                             *
*  Retour      : true si l'opération s'est bien déroulée, false sinon.        *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/
bool load_format_from_raw_line(operands_format *format, const char *raw)
{
    bool result;                            /* Bilan à faire remonter      */
    YY_BUFFER_STATE state;                  /* Support d'analyse           */
    int status;                             /* Bilan de l'analyse          */
    state = yy_scan_string(raw);
    status = yyparse(format);
    result = (status == 0);
    yy_delete_buffer(state);
    return result;
}
 |