align TOK_TOKEN state change of translate() and translate2() to all other parsers

This commit is contained in:
stefan schippers 2023-05-02 18:54:27 +02:00
parent 5feb4539c7
commit 7e1f591b18
1 changed files with 12 additions and 11 deletions

View File

@ -2428,7 +2428,6 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level
( (space || c == '%' || c == '@') && !escape ) ||
( (!space && c != '%' && c != '@') && escape )
)
) {
state=TOK_SEP;
}
@ -2957,13 +2956,12 @@ const char *translate(int inst, const char* s)
else escape=0;
space=SPACE(c);
if( state==TOK_BEGIN && (c=='@' || c=='%' ) && !escape ) state=TOK_TOKEN; /* 20161210 escape */
else if( state==TOK_TOKEN && (
(space && !escape) ||
(c =='@' || c == '%') ||
(!space && escape)
)
&& token_pos > 1 ) state=TOK_SEP;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '%' || c == '@') && !escape ) ||
( (!space && c != '%' && c != '@') && escape )
)
) state=TOK_SEP;
STR_ALLOC(&result, result_pos, &size);
STR_ALLOC(&token, token_pos, &sizetok);
@ -3571,9 +3569,12 @@ const char *translate2(Lcc *lcc, int level, char* s)
else escape = 0;
space = SPACE(c);
if (state == TOK_BEGIN && c == '@' && !escape) state = TOK_TOKEN;
else if (state == TOK_TOKEN && ( (space && !escape) || c == '@' || (!space && escape)) && token_pos > 1) {
state = TOK_SEP;
}
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '@') && !escape ) ||
( (!space && c != '@') && escape )
)
) state=TOK_SEP;
STR_ALLOC(&result, result_pos, &size);
STR_ALLOC(&token, token_pos, &sizetok);
if (state == TOK_TOKEN) token[token_pos++] = (char)c;