bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ylwrap proposition


From: Sergey Poznyakoff
Subject: Re: ylwrap proposition
Date: Sat, 23 Jun 2007 15:04:29 +0300

Ralf Wildenhues <address@hidden> ha escrit:

> Can s/yy/.../ change anything unintended?  E.g., do we need to ensure it
> only changes words beginning with yy?

In theory it could, for example if the programmer used identifiers
beginning with, or containing `yy'. However, I can hardly imagine
someone who does that. At least, all yacc manuals declare that `yy'
prefix is reserved for yacc/lex identifiers and explicitly discourage
its use in application identifiers.

It would be preferable, of course, to change only those `yy' that occur
at the beginning of words. But I cannot figure out a portable way of
doing so in sed.

Anyways, the similar ylwrap version was used by GNU mailutils and
radius for the last six years, without apparent problems.

> Can it omit anything that needs changed (what about `YY...')?

The purpose of the `--prefix' option is to make it possible for a
program to contain several parsers without name clashes. All identifiers
starting with `YY' are macros and they are not used outside the y.tab.c
source, or, at the very most, outside of y.tab.c and the corresponding
lexical analizer, so they will not cause name clashes either.

> What about the header file, doesn't that need to be changed as well?

It will be changed as well, if specified in the command line:

   ylwrap --prefix fmt \
       mh_fmtgram.y y.tab.c fmtgram.c y.tab.h fmtgram.h -- yacc -d

> Does the renaming work for extensions such as bison's for C++ parsers?

I never tried. I will test this.

>  ylwrap is used for both lex and yacc:
> should we disable the functionality for lex (as it may produce garbage
> there?), and should it be made clear in the help output that -p is only
> for the yacc part?

No, on the contrary, it is important that lex sources be processed as
well. They follow the same naming scheme as grammars and it is necessary
for proper parser-lexer interaction.

> This patch needs the following things to be complete.  If you are
> willing to help with any of them, that'd be great.

No problem.

> - update scriptversion and copyright year in the ylwrap script.
> - add test(s) to ensure the new functionality works as expected.
>   tests/yacc8.test can serve as a starting point for a new test.
> - write ChangeLog entry, adjust NEWS, THANKS, doc/automake.texi:
>   mention new option, change recommendation about multiple parsers
>   (probably the list of #defines should not be removed just yet,
>   it may be interesting if only for historical purposes).

Allow me a couple of days to do that.

> > +  --p|--pr|--pre|--pref|--prefi|--prefix)
> 
> -p is not actually supported, but documented.

Oh, yes. I'll fix it.
 
> Let's just rewrite the whole thing like:
> 
>   sed -e "
>     $YYREPL
>     /^#/!b
>     s,$input_rx,,
>     s,$from,$2,
>     s,$FROM,$TARGET," "$from" >"$target" || ret=$?

OK

Regards,
Sergey




reply via email to

[Prev in Thread] Current Thread [Next in Thread]