+
+2013-12-05 Christos Zoulas <christos@zoulas.com>
+
+ * Change the way we handle multiple lex scanners and yacc parsers
+ in a single program. Our old patch to ylwrap does not work anymore
+ because the bison parsers need shared symbols that start with yy
+ and we can't easily select which ones work. So now we use -P and
+ -p to let lex and yacc do the work for us. This requires a patch
+ to ylwrap, but it is smaller.
+
+
+2013-12-05 Christos Zoulas <christos@zoulas.com>
+
+ * Change the way we handle multiple lex scanners and yacc parsers
+ in a single program. Our old patch to ylwrap does not work anymore
+ because the bison parsers need shared symbols that start with yy
+ and we can't easily select which ones work. So now we use -P and
+ -p to let lex and yacc do the work for us. This requires a patch
+ to ylwrap, but it is smaller.
+
2013-05-14 Christos Zoulas <christos@zoulas.com>
* update to handle new autoconf and regen files
\[ {
dprintf("%8d: Left bracket \"%s\"\n", yytext);
- yylval.strtype = xstrdup(yytext);
+ conf_lval.strtype = xstrdup(yytext);
amu_return(LEFT_BRACKET);
}
\] {
dprintf("%8d: Right bracket \"%s\"\n", yytext);
- yylval.strtype = xstrdup(yytext);
+ conf_lval.strtype = xstrdup(yytext);
amu_return(RIGHT_BRACKET);
}
= {
dprintf("%8d: Equal \"%s\"\n", yytext);
- yylval.strtype = xstrdup(yytext);
+ conf_lval.strtype = xstrdup(yytext);
amu_return(EQUAL);
}
{NONWSCHAR}{NONWSCHAR}* {
dprintf("%8d: Non-WS string \"%s\"\n", yytext);
- yylval.strtype = xstrdup(yytext);
+ conf_lval.strtype = xstrdup(yytext);
amu_return(NONWS_STRING);
}
dprintf("%8d: QUOTED-Non-WS-EQ string \"%s\"\n", yytext);
/* must strip quotes */
yytext[strlen((char *)yytext)-1] = '\0';
- yylval.strtype = xstrdup(&yytext[1]);
+ conf_lval.strtype = xstrdup(&yytext[1]);
amu_return(QUOTED_NONWSEQ_STRING);
}
{NONWSEQCHAR}{NONWSEQCHAR}* {
dprintf("%8d: Non-WS-EQ string \"%s\"\n", yytext);
- yylval.strtype = xstrdup(yytext);
+ conf_lval.strtype = xstrdup(yytext);
amu_return(NONWSEQ_STRING);
}
#endif /* FLEX_SCANNER */
int yylex(void);
-int yyerror(const char *);
+int sun_map_error(const char *);
/*
* We need to configure lex to parse from a string
{WORD_REX} {
sun_map_tokpos += yyleng;
- xstrlcpy((char *)yylval.strval,(const char *)yytext,sizeof(yylval.strval));
+ xstrlcpy((char *)sun_map_lval.strval,(const char *)yytext,sizeof(sun_map_lval.strval));
return WORD;
}
int
-yyerror(const char* s)
+sun_map_error(const char* s)
{
return 1;
}
echo "AMU: Fixing ylwrap..."
patch << \EOF
---- ylwrap.orig 2013-05-14 20:00:39.000000000 -0400
-+++ ylwrap 2013-05-14 20:06:06.000000000 -0400
-@@ -199,8 +199,24 @@
- # include guards too.
- FROM=`guard "$from"`
- TARGET=`guard "$to"`
-+
-+ prefix=`echo $input | sed \
-+ -e 's,^.*/,,g' \
-+ -e 's/_parse.[yl]$/_/g' \
-+ -e 's/_tok.[yl]$/_/g'`
+--- ylwrap.orig 2013-12-02 19:42:59.239979147 -0500
++++ ylwrap 2013-12-02 19:42:36.559379132 -0500
+@@ -96,6 +96,23 @@
+ *[\\/]*) prog="`pwd`/$prog" ;;
+ esac
+
++set -x
++prefix=`echo $input | sed \
++ -e 's,^.*/,,g' \
++ -e 's/_gram.[yl]$/_/g' \
++ -e 's/_lex.[yl]$/_/g' \
++ -e 's/_parse.[yl]$/_/g' \
++ -e 's/_tok.[yl]$/_/g'`
+
-+ case $prefix in
-+ *.y)
-+ code_prefix="$(basename $prefix _gram.y)_yy";;
-+ *.l)
-+ code_prefix="$(basename $prefix _lex.l)_yy";;
-+ *)
-+ code_prefix="$prefix";;
-+ esac
++case "$prog" in
++*lex)
++ flags="-P $prefix"
++ out="mv lex.$prefix.c lex.yy.c"
++ ;;
++yacc|bison)
++ flags="-p $prefix";;
++esac
+
- sed -e "/^#/!b" -e "s|$input_rx|$input_sub_rx|" -e "$rename_sed" \
-- -e "s|$FROM|$TARGET|" "$from" >"$target" || ret=$?
-+ -e "s|$FROM|$TARGET|" "$from" | sed -e "s|yy|$code_prefix|g" > \
-+ "$target" || ret=$?
+ # FIXME: add hostname here for parallel makes that run commands on
+ # other machines. But that might take us over the 14-char limit.
+ dirname=ylwrap$$
+@@ -105,10 +122,13 @@
+ cd $dirname
+
+ case $# in
+- 0) "$prog" "$input" ;;
+- *) "$prog" "$@" "$input" ;;
++ 0) "$prog" $flags "$input" ;;
++ *) "$prog" $flags "$@" "$input" ;;
+ esac
+ ret=$?
++if [ -n "$out" ]; then
++ eval $out
++fi
- # Check whether files must be updated.
- if test "$from" != "$parser"; then
-\EOF
+ if test $ret -eq 0; then
+ set X $pairlist
+EOF
# save timestamp
echo "AMU: save timestamp..."
int yywrap(void);
#endif /* not yywrap or yylex */
-int yyerror(const char *, ...);
+int fsi_error(const char *, ...);
YYSTYPE yylval;
static char *fsi_filename;
<F>[={}] { return *yytext; }
<F>\" { BEGIN Q; optr = ostr; quoted = 1; }
-<Q>\n { ayylineno++; yyerror("\" expected"); BEGIN F; }
+<Q>\n { ayylineno++; fsi_error("\" expected"); BEGIN F; }
<Q>\\b { *optr++ = '\b'; /* escape */ }
<Q>\\t { *optr++ = '\t'; /* escape */ }
<Q>\\\" { *optr++ = '\"'; /* escape */ }
<Q>\\n { *optr++ = '\n'; /* escape */ }
<Q>\\f { *optr++ = '\f'; /* escape */ }
<Q>"\\ " { *optr++ = ' '; /* force space */ }
-<Q>\\. { yyerror("Unknown \\ sequence"); }
+<Q>\\. { fsi_error("Unknown \\ sequence"); }
<Q>([ \t]|"\\\n"){2,} { char *p = (char *) yytext-1; while ((p = strchr(p+1, '\n'))) ayylineno++; }
<Q>\" { BEGIN F; quoted = 0;
*optr = '\0';
int
-yyerror(const char *fmt, ...)
+fsi_error(const char *fmt, ...)
{
va_list ap;
int m = 1 << k;
if (hp->h_mask & m) {
- fsi_yyerror("host field \"%s\" already set", host_strings[k]);
+ fsi_error("host field \"%s\" already set", host_strings[k]);
return;
}
hp->h_mask |= m;
dict_ent *de = dict_locate(dict_of_hosts, v);
if (de)
- fsi_yyerror("duplicate host %s!", v);
+ fsi_error("duplicate host %s!", v);
else
dict_add(dict_of_hosts, v, (char *) hp);
hp->h_hostname = v;
int m = 1 << k;
if (ep->e_mask & m) {
- fsi_yyerror("netif field \"%s\" already set", ether_if_strings[k]);
+ fsi_error("netif field \"%s\" already set", ether_if_strings[k]);
return;
}
ep->e_mask |= m;
case EF_INADDR:{
ep->e_inaddr.s_addr = inet_addr(v);
if ((int) ep->e_inaddr.s_addr == (int) INADDR_NONE)
- fsi_yyerror("malformed IP dotted quad: %s", v);
+ fsi_error("malformed IP dotted quad: %s", v);
XFREE(v);
}
break;
if ((sscanf(v, "0x%lx", &nm) == 1 || sscanf(v, "%lx", &nm) == 1) && nm != 0)
ep->e_netmask = htonl(nm);
else
- fsi_yyerror("malformed netmask: %s", v);
+ fsi_error("malformed netmask: %s", v);
XFREE(v);
}
break;
int m = 1 << k;
if (dp->d_mask & m) {
- fsi_yyerror("fs field \"%s\" already set", disk_fs_strings[k]);
+ fsi_error("fs field \"%s\" already set", disk_fs_strings[k]);
return;
}
dp->d_mask |= m;
int m = 1 << k;
if (mp->m_mask & m) {
- fsi_yyerror("mount tree field \"%s\" already set", mount_strings[k]);
+ fsi_error("mount tree field \"%s\" already set", mount_strings[k]);
return;
}
mp->m_mask |= m;
int m = 1 << k;
if (fp->f_mask & m) {
- fsi_yyerror("mount field \"%s\" already set", fsmount_strings[k]);
+ fsi_error("mount field \"%s\" already set", fsmount_strings[k]);
return;
}
fp->f_mask |= m;
* Parse input
*/
show_area_being_processed("read config", 11);
- if (fsi_yyparse())
+ if (fsi_parse())
errors = 1;
errors += file_io_errors + parse_errors;
extern void show_new(char *msg);
extern void warning(void);
-extern int yyerror(const char *fmt, ...)
- __attribute__((__format__(__printf__, 1, 2)));
-extern int fsi_yyerror(const char *fmt, ...)
+extern int fsi_error(const char *fmt, ...)
__attribute__((__format__(__printf__, 1, 2)));
extern void domain_strip(char *otherdom, char *localdom);
/*
#ifndef yywrap
extern int yywrap(void);
#endif /* not yywrap */
-extern int yyparse(void);
-extern int fsi_yyparse(void);
+extern int fsi_parse(void);
extern int write_atab(qelem *q);
extern int write_bootparams(qelem *q);
extern int write_dumpset(qelem *q);
extern void col_cleanup(int eoj);
extern void set_host(host *hp, int k, char *v);
extern void set_ether_if(ether_if *ep, int k, char *v);
-extern int yylex(void);
-extern int fsi_yylex(void);
+extern int fsi_lex(void);
#define BITSET(m,b) ((m) |= (1<<(b)))
%{
#include "null_gram.h"
-void yyerror(const char *fmt, ...) {}
+void null_error(const char *fmt, ...) {}
int yywrap(void) { return 0; }
%}
%option nounput