Mail Archives: djgpp/1994/10/14/06:38:28
First thanks to all who have responded. The byacc (Berkeley yacc) is
available on Simtel mirrors in .../pgmutil/byacc19.zip or perhaps a
more recent version. Unfortunately the problem seems to stem from the
Flex output as illustarted below.
The makefile contains:
lex.yy.c: lexsource
lex lexsource
ex lex.yy.c < fixer
y.tab.c: lex.yy.c yaccsource
yacc yaccsource
y.tab.o: lex.yy.c y.tab.c
Note the inter-dependencies. I replaced lex.yy.c with lexyy.c and
y.tab.c with y_tab.c, lex with "flex -l" and yacc with bison. Fixer
is:
1a
extern int get_sig_char();
.
.,$s/getc(yyin)/get_sig_char()
:wq
which seems to replace getc(yyin) with get_sig_char()
> However ,I doubt that there can be a general library function for
it. > yyless() interacts heavily with scanner internals.
> Flex implements it as a macro and it is thus available only within flex file.
> See also flex docs for yyless() and example of an infinite loop.
This is an excerpt from the lexyy.c generated by "flex -l lexsource"
(DJGPP port of flex 2.4.7)
The ....... indicates stuff cut out to conserve bandwidth.
----------------------lexyy.c-------------
...........
..........
/* The funky do-while in the following #define is used to turn the
definition
* int a single C statement (which needs a semi-colon terminator).
This
* avoids problems with code like:
*
* if ( condition_holds )
* yyless( 5 );
* else
* do_something_else();
*
* Prior to using the do-while the compiler would get upset at the
* "else" because it interpreted the "if" statement as being all
* done when it reached the ';' after the yyless() call.
*/
/* Return all but the first 'n' matched characters back to the input
stream. */
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
*yy_cp = yy_hold_char; \
yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
.......................
.......................
while ( 1 ) /* loops until end-of-file is reached */
{
...................
...................
case 37:
YY_USER_ACTION
# line 61 "lexsource"
{
yyless(yyleng - 1); /* we'll want to send the '(' as it's own
token */
strcpy(yylval.sval, yytext);
return(MATH_FUNC1);
}
YY_BREAK
....................
....................
} /* end of scanning one token */
} /* end of yylex */
....................
....................
/* Redefine yyless() so it works in section 3 code. */
#undef yyless
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
yytext[yyleng] = yy_hold_char; \
yy_c_buf_p = yytext + n - YY_MORE_ADJ; \
yy_hold_char = *yy_c_buf_p; \
*yy_c_buf_p = '\0'; \
yyleng = n; \
} \
while ( 0 )
......................
......................
>
The inline definitions geneertaed by Flex don't look right to me. Any
comments from the experts? (is a patch required for the lexyy.c
output from Flex?)
> BTW: do you scan text with 8:th bit set. If so and you don't use
> flex 8 bit option flex used to jam.
Can you elaborate on this.
Tony.
- Raw text -