1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-07-30 13:05:50 +03:00

0030053: STEP read fails due to comment string

- Update .step scanner:
  - add rules to read anything within the comment
  - add a function to initialize of lexical scanner
  - add states for Commit & End instead of global variables modcom & modend
This commit is contained in:
dpasukhi 2020-09-09 13:00:15 +03:00 committed by abv
parent e0a25f3d93
commit 183c99caf8
4 changed files with 270 additions and 216 deletions

View File

@ -308,42 +308,44 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
*yy_cp = '\0'; \ *yy_cp = '\0'; \
yy_c_buf_p = yy_cp; yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 37 #define YY_NUM_RULES 40
#define YY_END_OF_BUFFER 38 #define YY_END_OF_BUFFER 41
static yyconst short int yy_acclist[146] = static yyconst short int yy_acclist[157] =
{ 0, { 0,
38, 36, 37, 1, 36, 37, 3, 36, 37, 4, 2, 2, 41, 38, 40, 5, 38, 40, 7, 38,
36, 37, 2, 36, 37, 36, 37, 36, 37, 36, 40, 8, 38, 40, 6, 38, 40, 38, 40, 38,
37, 18, 36, 37, 36, 37, 36, 37, 15, 36, 40, 38, 40, 22, 38, 40, 38, 40, 38, 40,
37, 16, 37, 36, 37, 9, 36, 37, 17, 36, 19, 38, 40, 20, 40, 13, 38, 40, 21, 38,
37, 36, 37, 31, 36, 37, 9, 34, 36, 37, 40, 38, 40, 33, 38, 40, 13, 36, 38, 40,
20, 36, 37, 19, 36, 37, 34, 36, 37, 34, 24, 38, 40, 23, 38, 40, 36, 38, 40, 36,
36, 37, 34, 36, 37, 34, 36, 37, 34, 36, 38, 40, 36, 38, 40, 36, 38, 40, 36, 38,
37, 34, 36, 37, 5, 36, 37, 35, 8,16391, 40, 36, 38, 40, 9, 38, 40, 2, 40, 7,
12, 22, 10, 9, 10, 10, 21, 9, 10, 34, 40, 3, 40, 39, 40, 37, 12,16395, 16, 14,
34, 34, 34, 34, 34, 34, 5, 13, 6, 8199, 13, 14, 14, 1, 13, 14, 36, 36, 36, 36,
10, 14, 14, 34, 34, 34, 34, 34, 34, 8199, 36, 36, 36, 9, 2, 3, 3, 4, 17, 10,
11, 11, 11, 34, 34, 34, 34, 34, 30, 34, 8203, 14, 18, 18, 36, 36, 36, 36, 36, 36,
11, 11, 11, 34, 26, 34, 34, 34, 34, 23, 8203, 15, 15, 15, 36, 36, 36, 36, 36, 32,
32, 34, 34, 34, 34, 34, 25, 34, 24, 29, 36, 15, 15, 15, 36, 28, 36, 36, 36, 36,
33, 34, 27, 28, 28 25, 34, 36, 36, 36, 36, 36, 27, 36, 26,
31, 35, 36, 29, 30, 30
} ; } ;
static yyconst short int yy_accept[109] = static yyconst short int yy_accept[119] =
{ 0, { 0,
1, 1, 1, 2, 4, 7, 10, 13, 16, 18, 1, 1, 1, 2, 3, 3, 3, 4, 6, 9,
20, 22, 25, 27, 29, 32, 34, 36, 39, 42, 12, 15, 18, 20, 22, 24, 27, 29, 31, 34,
44, 47, 51, 54, 57, 60, 63, 66, 69, 72, 36, 39, 42, 44, 47, 51, 54, 57, 60, 63,
75, 78, 79, 79, 81, 81, 81, 81, 82, 83, 66, 69, 72, 75, 78, 80, 82, 84, 86, 87,
84, 86, 87, 87, 88, 91, 92, 93, 94, 95, 87, 89, 89, 89, 89, 90, 91, 93, 94, 94,
96, 97, 98, 99, 99, 101, 101, 101, 103, 103, 95, 98, 99, 100, 101, 102, 103, 104, 105, 106,
104, 105, 106, 107, 108, 109, 110, 111, 111, 112, 107, 108, 109, 110, 110, 112, 112, 112, 114, 114,
113, 115, 116, 116, 117, 118, 118, 119, 120, 121, 115, 116, 117, 118, 119, 120, 121, 122, 122, 123,
121, 122, 123, 125, 126, 126, 127, 128, 129, 130, 124, 126, 127, 127, 128, 129, 129, 130, 131, 132,
131, 132, 132, 133, 134, 135, 136, 136, 137, 138, 132, 133, 134, 136, 137, 137, 138, 139, 140, 141,
139, 140, 140, 141, 143, 145, 146, 146 142, 143, 143, 144, 145, 146, 147, 147, 148, 149,
150, 151, 151, 152, 154, 156, 157, 157
} ; } ;
static yyconst int yy_ec[256] = static yyconst int yy_ec[256] =
@ -381,105 +383,119 @@ static yyconst int yy_ec[256] =
static yyconst int yy_meta[40] = static yyconst int yy_meta[40] =
{ 0, { 0,
1, 2, 3, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 2, 2, 5, 2,
5, 2, 2, 5, 5, 5, 5, 5, 6, 6, 6, 2, 2, 6, 6, 6, 6, 6, 7, 7,
6, 6, 6, 6, 6, 6, 6, 7, 2 7, 7, 7, 7, 7, 7, 7, 8, 2
} ; } ;
static yyconst short int yy_base[114] = static yyconst short int yy_base[128] =
{ 0, { 0,
0, 0, 209, 210, 210, 210, 210, 210, 0, 0, 0, 0, 37, 38, 248, 247, 249, 252, 252, 252,
187, 210, 171, 37, 210, 210, 186, 22, 210, 23, 252, 252, 0, 0, 227, 252, 211, 39, 252, 252,
190, 26, 210, 210, 185, 27, 29, 31, 33, 34, 24, 252, 25, 231, 28, 252, 252, 226, 31, 29,
164, 0, 194, 52, 175, 52, 53, 188, 210, 49, 35, 37, 38, 205, 0, 252, 44, 252, 0, 235,
53, 57, 180, 210, 61, 179, 47, 60, 38, 64, 56, 216, 57, 62, 229, 57, 61, 62, 221, 252,
67, 158, 210, 86, 210, 163, 75, 79, 83, 210, 65, 220, 51, 68, 47, 72, 73, 199, 0, 52,
87, 91, 93, 94, 98, 99, 210, 161, 173, 103, 79, 252, 252, 94, 252, 204, 86, 87, 93, 252,
104, 41, 158, 108, 107, 110, 0, 210, 118, 139, 100, 79, 104, 101, 108, 91, 252, 197, 202, 112,
144, 120, 123, 210, 125, 119, 124, 127, 95, 210, 113, 116, 185, 117, 118, 126, 0, 252, 120, 187,
210, 61, 128, 129, 130, 134, 136, 140, 210, 141, 156, 130, 131, 252, 140, 122, 134, 137, 78, 252,
210, 148, 210, 71, 0, 0, 210, 166, 62, 172, 252, 136, 138, 139, 140, 144, 146, 143, 252, 151,
176, 179, 186 252, 157, 252, 105, 0, 0, 252, 179, 187, 190,
62, 197, 201, 204, 212, 220, 228
} ; } ;
static yyconst short int yy_def[114] = static yyconst short int yy_def[128] =
{ 0, { 0,
107, 1, 107, 107, 107, 107, 107, 107, 108, 109, 117, 1, 118, 118, 119, 119, 117, 117, 117, 117,
107, 107, 107, 110, 107, 107, 107, 107, 107, 111, 117, 117, 120, 121, 117, 117, 117, 122, 117, 117,
107, 112, 107, 107, 112, 112, 112, 112, 112, 112, 117, 117, 123, 117, 124, 117, 117, 124, 124, 124,
107, 108, 109, 107, 107, 110, 110, 107, 107, 107, 124, 124, 124, 117, 125, 117, 126, 117, 120, 121,
107, 111, 111, 107, 112, 112, 112, 112, 112, 112, 117, 117, 122, 122, 117, 117, 117, 123, 123, 117,
112, 107, 107, 107, 107, 107, 107, 107, 111, 107, 124, 124, 124, 124, 124, 124, 124, 117, 125, 126,
112, 112, 112, 112, 112, 112, 107, 107, 107, 111, 126, 117, 117, 117, 117, 117, 117, 117, 123, 117,
112, 112, 107, 112, 112, 107, 65, 107, 112, 107, 124, 124, 124, 124, 124, 124, 117, 117, 117, 123,
107, 111, 112, 107, 107, 112, 112, 112, 112, 107, 124, 124, 117, 124, 124, 117, 75, 117, 124, 117,
107, 107, 112, 112, 112, 112, 107, 112, 107, 112, 117, 123, 124, 117, 117, 124, 124, 124, 124, 117,
107, 107, 107, 112, 113, 113, 0, 107, 107, 107, 117, 117, 124, 124, 124, 124, 117, 124, 117, 124,
107, 107, 107 117, 117, 117, 124, 127, 127, 0, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117
} ; } ;
static yyconst short int yy_nxt[250] = static yyconst short int yy_nxt[292] =
{ 0, { 0,
4, 5, 6, 4, 7, 8, 9, 10, 11, 12, 8, 9, 10, 8, 11, 12, 13, 14, 15, 16,
13, 14, 15, 16, 17, 18, 19, 18, 20, 21, 17, 18, 19, 20, 8, 21, 22, 21, 23, 24,
22, 23, 24, 25, 25, 25, 26, 27, 25, 28, 25, 26, 27, 28, 28, 28, 29, 30, 28, 31,
29, 25, 25, 25, 25, 30, 25, 25, 31, 37, 32, 28, 28, 28, 28, 33, 28, 28, 34, 36,
40, 40, 41, 42, 40, 107, 45, 107, 38, 107, 36, 44, 46, 46, 47, 48, 46, 117, 51, 117,
47, 107, 107, 54, 37, 37, 107, 54, 49, 107, 45, 37, 37, 117, 53, 117, 117, 64, 61, 44,
48, 64, 84, 38, 38, 107, 33, 40, 50, 40, 54, 64, 55, 62, 44, 117, 117, 40, 45, 117,
51, 40, 34, 41, 55, 58, 57, 42, 107, 40, 74, 117, 56, 45, 57, 46, 41, 46, 65, 46,
57, 45, 107, 62, 59, 107, 63, 54, 61, 107, 68, 47, 48, 46, 67, 51, 117, 72, 67, 69,
69, 54, 69, 97, 66, 69, 65, 40, 69, 40, 117, 117, 71, 61, 73, 64, 117, 117, 62, 64,
69, 60, 69, 70, 69, 107, 57, 71, 67, 107, 76, 79, 82, 79, 75, 46, 79, 46, 79, 117,
73, 107, 107, 107, 72, 76, 107, 107, 77, 78, 79, 70, 106, 80, 67, 79, 77, 79, 117, 117,
75, 60, 107, 82, 83, 107, 107, 76, 74, 96, 81, 83, 117, 117, 89, 86, 117, 85, 87, 88,
76, 78, 79, 86, 89, 87, 107, 107, 60, 90, 70, 117, 92, 93, 117, 117, 117, 94, 117, 84,
82, 107, 107, 83, 88, 107, 107, 107, 107, 94, 117, 100, 96, 86, 97, 99, 86, 88, 70, 117,
99, 93, 107, 102, 95, 101, 102, 103, 107, 107, 92, 93, 117, 98, 103, 117, 117, 117, 117, 104,
92, 98, 105, 100, 81, 102, 91, 104, 102, 103, 109, 117, 117, 112, 105, 111, 112, 113, 107, 117,
32, 32, 32, 36, 36, 36, 36, 36, 36, 43, 114, 108, 115, 110, 112, 102, 91, 112, 113, 35,
43, 43, 46, 46, 46, 46, 106, 106, 85, 106, 35, 35, 35, 35, 35, 35, 35, 38, 38, 38,
106, 106, 106, 81, 80, 68, 52, 107, 60, 36, 38, 38, 38, 38, 38, 39, 39, 39, 43, 43,
43, 43, 43, 43, 43, 49, 49, 49, 52, 52,
52, 52, 59, 59, 101, 95, 59, 59, 59, 59,
60, 60, 91, 60, 60, 60, 60, 60, 116, 116,
90, 116, 116, 116, 116, 116, 78, 58, 117, 70,
43, 66, 63, 58, 117, 50, 42, 41, 117, 36,
36, 7, 117, 117, 117, 117, 117, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
117
56, 53, 52, 107, 44, 39, 35, 34, 107, 3,
107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107
} ; } ;
static yyconst short int yy_chk[250] = static yyconst short int yy_chk[292] =
{ 0, { 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 14, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
18, 20, 18, 20, 22, 26, 22, 27, 14, 28, 4, 18, 21, 23, 21, 23, 25, 30, 25, 29,
26, 29, 30, 34, 36, 37, 49, 34, 28, 72, 18, 3, 4, 31, 29, 32, 33, 41, 37, 43,
27, 49, 72, 36, 37, 47, 109, 40, 29, 40, 30, 41, 31, 37, 44, 55, 60, 121, 43, 53,
30, 41, 34, 41, 34, 42, 40, 42, 48, 45, 55, 60, 32, 44, 33, 46, 41, 46, 41, 47,
41, 45, 50, 47, 42, 51, 48, 54, 45, 104, 48, 47, 48, 51, 46, 51, 54, 53, 47, 48,
57, 54, 57, 92, 51, 57, 50, 58, 59, 58, 56, 57, 51, 61, 54, 64, 99, 72, 61, 64,
59, 59, 61, 59, 61, 61, 58, 61, 54, 62, 57, 67, 72, 67, 56, 68, 67, 68, 69, 76,
63, 63, 64, 89, 62, 65, 65, 66, 65, 65, 69, 69, 99, 69, 68, 71, 64, 71, 71, 74,
64, 70, 71, 70, 71, 75, 74, 76, 63, 89, 71, 73, 73, 114, 76, 75, 75, 74, 75, 75,
76, 76, 66, 74, 75, 74, 79, 86, 82, 79, 80, 81, 80, 81, 82, 84, 85, 82, 89, 73,
82, 83, 87, 83, 74, 88, 93, 94, 95, 87, 96, 89, 84, 86, 84, 85, 86, 86, 92, 93,
94, 86, 96, 97, 88, 96, 97, 97, 98, 100, 92, 93, 97, 84, 96, 98, 103, 104, 105, 97,
85, 93, 100, 95, 81, 102, 80, 98, 102, 102, 104, 108, 106, 107, 98, 106, 107, 107, 102, 110,
108, 108, 108, 110, 110, 110, 110, 110, 110, 111, 108, 103, 110, 105, 112, 95, 91, 112, 112, 118,
111, 111, 112, 112, 112, 112, 113, 113, 73, 113, 118, 118, 118, 118, 118, 118, 118, 119, 119, 119,
113, 113, 113, 69, 68, 56, 52, 46, 43, 38, 119, 119, 119, 119, 119, 120, 120, 120, 122, 122,
122, 122, 122, 122, 122, 123, 123, 123, 124, 124,
124, 124, 125, 125, 90, 83, 125, 125, 125, 125,
126, 126, 79, 126, 126, 126, 126, 126, 127, 127,
78, 127, 127, 127, 127, 127, 66, 58, 52, 49,
45, 42, 40, 34, 28, 24, 17, 15, 7, 6,
5, 117, 117, 117, 117, 117, 117, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
117
35, 33, 31, 25, 21, 17, 13, 11, 3, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107
} ; } ;
static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
@ -560,18 +576,29 @@ void steprestart ( FILE *input_file );
void rec_restext(char *newtext, int lentext); void rec_restext(char *newtext, int lentext);
void rec_typarg(int argtype); void rec_typarg(int argtype);
int steplineno; /* Comptage de ligne (ben oui, fait tout faire) */ /* Counter of lines in the file */
int steplineno;
int modcom = 0; /* Commentaires type C */ /* Reset the lexical scanner before reading */
int modend = 0; /* Flag for finishing of the STEP file */ void rec_inityyll()
void resultat () /* Resultat alloue dynamiquement, "jete" une fois lu */ {
{ if (modcom == 0) rec_restext(yytext,yyleng); } yy_init = yy_start = 1;
}
/* Record current match (text string) for further processing */
void resultat()
{
rec_restext(yytext,yyleng);
}
// disable GCC warnings in flex code // disable GCC warnings in flex code
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-function"
#endif #endif
#define Com 1
#define End 2
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
@ -770,14 +797,14 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 108 ) if ( yy_current_state >= 118 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
*yy_state_ptr++ = yy_current_state; *yy_state_ptr++ = yy_current_state;
++yy_cp; ++yy_cp;
} }
while ( yy_base[yy_current_state] != 210 ); while ( yy_base[yy_current_state] != 252 );
yy_find_action: yy_find_action:
yy_current_state = *--yy_state_ptr; yy_current_state = *--yy_state_ptr;
@ -828,156 +855,170 @@ do_action: /* This label is used only to access EOF actions. */
{ /* beginning of action switch */ { /* beginning of action switch */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
{;} { BEGIN(Com); } /* start of comment - put the scanner in the "Com" state */
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
{;} {;} /* in comment, skip any characters except asterisk (and newline, handled by its own rule) */
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
{ steplineno ++; } {;} /* in comment, skip any sequence of asterisks followed by other symbols (except slash or newline) */
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
{;} /* abv 30.06.00: for reading DOS files */ { BEGIN(INITIAL); } /* end of comment - reset the scanner to initial state */
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
{;} /* fix from C21. for test load e3i file with line 15 with null symbols */ {;}
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP
{;}
YY_BREAK
case 7:
YY_RULE_SETUP
{ steplineno ++; } /* count lines (one rule for all start conditions) */
YY_BREAK
case 8:
YY_RULE_SETUP
{;} /* abv 30.06.00: for reading DOS files */
YY_BREAK
case 9:
YY_RULE_SETUP
{;} /* fix from C21. for test load e3i file with line 15 with null symbols */
YY_BREAK
case 10:
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
yy_c_buf_p = yy_cp -= 1; yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) return(ENTITY); } { resultat(); return(ENTITY); }
YY_BREAK
case 7:
YY_RULE_SETUP
{ resultat(); if (modcom == 0) return(ENTITY); }
YY_BREAK
case 8:
YY_RULE_SETUP
{ resultat(); if (modcom == 0) return(IDENT); }
YY_BREAK
case 9:
YY_RULE_SETUP
{ resultat(); if (modcom == 0) { rec_typarg(rec_argInteger); return(QUID); } }
YY_BREAK
case 10:
YY_RULE_SETUP
{ resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } }
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } } { resultat(); return(ENTITY); }
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) { rec_typarg(rec_argText); return(QUID); } } { resultat(); return(IDENT); }
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) { rec_typarg(rec_argHexa); return(QUID); } } { resultat(); rec_typarg(rec_argInteger); return(QUID); }
YY_BREAK YY_BREAK
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) { rec_typarg(rec_argEnum); return(QUID); } } { resultat(); rec_typarg(rec_argFloat); return(QUID); }
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return ('('); } { resultat(); rec_typarg(rec_argFloat); return(QUID); }
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return (')'); } { resultat(); rec_typarg(rec_argText); return(QUID); }
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return (','); } { resultat(); rec_typarg(rec_argHexa); return(QUID); }
YY_BREAK YY_BREAK
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) { rec_typarg(rec_argNondef); return(QUID); } } { resultat(); rec_typarg(rec_argEnum); return(QUID); }
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return ('='); } { return ('('); }
YY_BREAK YY_BREAK
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return (';'); } { return (')'); }
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
{ modcom = 1; } { return (','); }
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modend == 0) modcom = 0; } { resultat(); rec_typarg(rec_argNondef); return(QUID); }
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return(STEP); } { return ('='); }
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return(HEADER); } { return (';'); }
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return(ENDSEC); } { return(STEP); }
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return(DATA); } { return(HEADER); }
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modend == 0) {modcom = 0; return(ENDSTEP);} } { return(ENDSEC); }
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modend == 0) {modcom = 0; return(ENDSTEP);} } { return(DATA); }
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
{ modcom = 1; modend = 1; return(ENDSTEP); } { return(ENDSTEP);}
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modend == 0) {modcom = 0; return(STEP); } } { return(ENDSTEP);}
YY_BREAK YY_BREAK
case 31: case 31:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return ('/'); } { BEGIN(End); return(ENDSTEP); } /* at the end of the STEP data, enter dedicated start condition "End" to skip everything that follows */
YY_BREAK YY_BREAK
case 32: case 32:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return(SCOPE); } { return(STEP); }
YY_BREAK YY_BREAK
case 33: case 33:
YY_RULE_SETUP YY_RULE_SETUP
{ if (modcom == 0) return(ENDSCOPE); } { return ('/'); }
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) return(TYPE); } { return(SCOPE); }
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) return(TYPE); } { return(ENDSCOPE); }
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); if (modcom == 0) { rec_typarg(rec_argMisc); return(QUID); } } { resultat(); return(TYPE); }
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
{ resultat(); return(TYPE); }
YY_BREAK
case 38:
YY_RULE_SETUP
{ resultat(); rec_typarg(rec_argMisc); return(QUID); }
YY_BREAK
case 39:
YY_RULE_SETUP
{;} /* skip any characters (except newlines) */
YY_BREAK
case 40:
YY_RULE_SETUP
ECHO; ECHO;
YY_BREAK YY_BREAK
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(Com):
case YY_STATE_EOF(End):
yyterminate(); yyterminate();
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
@ -1263,7 +1304,7 @@ static yy_state_type yy_get_previous_state()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 108 ) if ( yy_current_state >= 118 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@ -1293,11 +1334,11 @@ yy_state_type yy_current_state;
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 108 ) if ( yy_current_state >= 118 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 107); yy_is_jam = (yy_current_state == 117);
if ( ! yy_is_jam ) if ( ! yy_is_jam )
*yy_state_ptr++ = yy_current_state; *yy_state_ptr++ = yy_current_state;

View File

@ -170,18 +170,7 @@ static char idzero[] = "#0";
void recfile_modeprint(int mode) void recfile_modeprint(int mode)
{ modeprint = mode; } { modeprint = mode; }
static int lastno; void rec_inityyll ();
extern int steplineno;
extern int modcom;
extern int modend;
void rec_inityyll ()
{
steplineno = 0;
modcom = 0;
modend = 0;
lastno = -1;
}
/* INITIALISATION */ /* INITIALISATION */

View File

@ -55,12 +55,20 @@ void steprestart ( FILE *input_file );
void rec_restext(char *newtext, int lentext); void rec_restext(char *newtext, int lentext);
void rec_typarg(int argtype); void rec_typarg(int argtype);
int steplineno; /* Comptage de ligne (ben oui, fait tout faire) */ /* Counter of lines in the file */
int steplineno;
int modcom = 0; /* Commentaires type C */ /* Reset the lexical scanner before reading */
int modend = 0; /* Flag for finishing of the STEP file */ void rec_inityyll()
void resultat () /* Resultat alloue dynamiquement, "jete" une fois lu */ {
{ if (modcom == 0) rec_restext(yytext,yyleng); } yy_init = yy_start = 1;
}
/* Record current match (text string) for further processing */
void resultat()
{
rec_restext(yytext,yyleng);
}
// disable GCC warnings in flex code // disable GCC warnings in flex code
#ifdef __GNUC__ #ifdef __GNUC__
@ -68,43 +76,49 @@ void rec_typarg(int argtype);
#endif #endif
%} %}
%x Com End
%% %%
"/*" { BEGIN(Com); } /* start of comment - put the scanner in the "Com" state */
<Com>[^*\n]* {;} /* in comment, skip any characters except asterisk (and newline, handled by its own rule) */
<Com>[*]+[^*/\n]* {;} /* in comment, skip any sequence of asterisks followed by other symbols (except slash or newline) */
<Com>[*]+[/] { BEGIN(INITIAL); } /* end of comment - reset the scanner to initial state */
" " {;} " " {;}
" " {;} " " {;}
[\n] { steplineno ++; } <*>[\n] { steplineno ++; } /* count lines (one rule for all start conditions) */
[\r] {;} /* abv 30.06.00: for reading DOS files */ [\r] {;} /* abv 30.06.00: for reading DOS files */
[\0]+ {;} /* fix from C21. for test load e3i file with line 15 with null symbols */ [\0]+ {;} /* fix from C21. for test load e3i file with line 15 with null symbols */
#[0-9]+/= { resultat(); if (modcom == 0) return(ENTITY); } #[0-9]+/= { resultat(); return(ENTITY); }
#[0-9]+/[ ]*= { resultat(); if (modcom == 0) return(ENTITY); } #[0-9]+/[ ]*= { resultat(); return(ENTITY); }
#[0-9]+ { resultat(); if (modcom == 0) return(IDENT); } #[0-9]+ { resultat(); return(IDENT); }
[-+0-9][0-9]* { resultat(); if (modcom == 0) { rec_typarg(rec_argInteger); return(QUID); } } [-+0-9][0-9]* { resultat(); rec_typarg(rec_argInteger); return(QUID); }
[-+\.0-9][\.0-9]+ { resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } } [-+\.0-9][\.0-9]+ { resultat(); rec_typarg(rec_argFloat); return(QUID); }
[-+\.0-9][\.0-9]+E[-+0-9][0-9]* { resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } } [-+\.0-9][\.0-9]+E[-+0-9][0-9]* { resultat(); rec_typarg(rec_argFloat); return(QUID); }
[\']([\n]|[\000\011-\046\050-\176\201-\237\240-\777]|[\047][\047])*[\'] { resultat(); if (modcom == 0) { rec_typarg(rec_argText); return(QUID); } } [\']([\n]|[\000\011-\046\050-\176\201-\237\240-\777]|[\047][\047])*[\'] { resultat(); rec_typarg(rec_argText); return(QUID); }
["][0-9A-F]+["] { resultat(); if (modcom == 0) { rec_typarg(rec_argHexa); return(QUID); } } ["][0-9A-F]+["] { resultat(); rec_typarg(rec_argHexa); return(QUID); }
[.][A-Z0-9_]+[.] { resultat(); if (modcom == 0) { rec_typarg(rec_argEnum); return(QUID); } } [.][A-Z0-9_]+[.] { resultat(); rec_typarg(rec_argEnum); return(QUID); }
[(] { if (modcom == 0) return ('('); } [(] { return ('('); }
[)] { if (modcom == 0) return (')'); } [)] { return (')'); }
[,] { if (modcom == 0) return (','); } [,] { return (','); }
[$] { resultat(); if (modcom == 0) { rec_typarg(rec_argNondef); return(QUID); } } [$] { resultat(); rec_typarg(rec_argNondef); return(QUID); }
[=] { if (modcom == 0) return ('='); } [=] { return ('='); }
[;] { if (modcom == 0) return (';'); } [;] { return (';'); }
"/*" { modcom = 1; }
"*/" { if (modend == 0) modcom = 0; }
STEP; { if (modcom == 0) return(STEP); } STEP; { return(STEP); }
HEADER; { if (modcom == 0) return(HEADER); } HEADER; { return(HEADER); }
ENDSEC; { if (modcom == 0) return(ENDSEC); } ENDSEC; { return(ENDSEC); }
DATA; { if (modcom == 0) return(DATA); } DATA; { return(DATA); }
ENDSTEP; { if (modend == 0) {modcom = 0; return(ENDSTEP);} } ENDSTEP; { return(ENDSTEP);}
"ENDSTEP;".* { if (modend == 0) {modcom = 0; return(ENDSTEP);} } "ENDSTEP;".* { return(ENDSTEP);}
END-ISO[0-9\-]*; { modcom = 1; modend = 1; return(ENDSTEP); } END-ISO[0-9\-]*; { BEGIN(End); return(ENDSTEP); } /* at the end of the STEP data, enter dedicated start condition "End" to skip everything that follows */
ISO[0-9\-]*; { if (modend == 0) {modcom = 0; return(STEP); } } ISO[0-9\-]*; { return(STEP); }
[/] { if (modcom == 0) return ('/'); } [/] { return ('/'); }
&SCOPE { if (modcom == 0) return(SCOPE); } &SCOPE { return(SCOPE); }
ENDSCOPE { if (modcom == 0) return(ENDSCOPE); } ENDSCOPE { return(ENDSCOPE); }
[a-zA-Z0-9_]+ { resultat(); if (modcom == 0) return(TYPE); } [a-zA-Z0-9_]+ { resultat(); return(TYPE); }
![a-zA-Z0-9_]+ { resultat(); if (modcom == 0) return(TYPE); } ![a-zA-Z0-9_]+ { resultat(); return(TYPE); }
[^)] { resultat(); if (modcom == 0) { rec_typarg(rec_argMisc); return(QUID); } } [^)] { resultat(); rec_typarg(rec_argMisc); return(QUID); }
<End>[^\n] {;} /* skip any characters (except newlines) */

10
tests/bugs/step/bug30053 Normal file
View File

@ -0,0 +1,10 @@
puts "==================================================="
puts " 0030533: STEP read fails due to comment string "
puts "==================================================="
puts ""
pload DCAF
ReadStep D [locate_data_file bug30053.stp]
Close D