mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
examples: improve some function prototypes
* examples/c/bistromathic/parse.y, examples/c/glr/c++-types.y, * examples/c/lexcalc/parse.y: Use const where appropriate. Avoid `yy` prefixes where it does not make sense. Avoid the `p` prefix for pointers.
This commit is contained in:
@@ -87,7 +87,7 @@
|
|||||||
yytoken_kind_t
|
yytoken_kind_t
|
||||||
yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc,
|
yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc,
|
||||||
const user_context *uctx);
|
const user_context *uctx);
|
||||||
void yyerror (YYLTYPE *loc, const user_context *uctx,
|
void yyerror (const YYLTYPE *loc, const user_context *uctx,
|
||||||
char const *format, ...)
|
char const *format, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
}
|
}
|
||||||
@@ -466,7 +466,7 @@ yyreport_syntax_error (const yypcontext_t *ctx, const user_context *uctx)
|
|||||||
|
|
||||||
|
|
||||||
// Called by yyparse on error.
|
// Called by yyparse on error.
|
||||||
void yyerror (YYLTYPE *loc, const user_context *uctx, char const *format, ...)
|
void yyerror (const YYLTYPE *loc, const user_context *uctx, char const *format, ...)
|
||||||
{
|
{
|
||||||
if (uctx->silent)
|
if (uctx->silent)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -68,8 +68,8 @@
|
|||||||
static void node_print (FILE *, const Node *);
|
static void node_print (FILE *, const Node *);
|
||||||
static Node *stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
static Node *stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
||||||
|
|
||||||
static void yyerror (YYLTYPE const * const llocp, const char *msg);
|
static void yyerror (YYLTYPE const * const loc, const char *msg);
|
||||||
static yytoken_kind_t yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
|
static yytoken_kind_t yylex (YYSTYPE *lval, YYLTYPE *lloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
%expect-rr 1
|
%expect-rr 1
|
||||||
@@ -138,7 +138,7 @@ yyerror (YYLTYPE const * const loc, const char *msg)
|
|||||||
FILE * input = NULL;
|
FILE * input = NULL;
|
||||||
|
|
||||||
yytoken_kind_t
|
yytoken_kind_t
|
||||||
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
|
yylex (YYSTYPE *lval, YYLTYPE *lloc)
|
||||||
{
|
{
|
||||||
static int lineNum = 1;
|
static int lineNum = 1;
|
||||||
static int colNum = 0;
|
static int colNum = 0;
|
||||||
@@ -165,8 +165,8 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
yytoken_kind_t tok;
|
yytoken_kind_t tok;
|
||||||
llocp->first_line = llocp->last_line = lineNum;
|
lloc->first_line = lloc->last_line = lineNum;
|
||||||
llocp->first_column = colNum;
|
lloc->first_column = colNum;
|
||||||
if (isalpha (c))
|
if (isalpha (c))
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
@@ -186,12 +186,12 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
|
|||||||
if (isupper ((unsigned char) buffer[0]))
|
if (isupper ((unsigned char) buffer[0]))
|
||||||
{
|
{
|
||||||
tok = TYPENAME;
|
tok = TYPENAME;
|
||||||
lvalp->TYPENAME = new_term (strcpy (malloc (i), buffer));
|
lval->TYPENAME = new_term (strcpy (malloc (i), buffer));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tok = ID;
|
tok = ID;
|
||||||
lvalp->ID = new_term (strcpy (malloc (i), buffer));
|
lval->ID = new_term (strcpy (malloc (i), buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -199,7 +199,7 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
|
|||||||
colNum += 1;
|
colNum += 1;
|
||||||
tok = c;
|
tok = c;
|
||||||
}
|
}
|
||||||
llocp->last_column = colNum;
|
lloc->last_column = colNum;
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc)
|
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc)
|
||||||
YY_DECL;
|
YY_DECL;
|
||||||
|
|
||||||
void yyerror (YYLTYPE *loc, const char *msg);
|
void yyerror (const YYLTYPE *loc, const char *msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emitted on top of the implementation file.
|
// Emitted on top of the implementation file.
|
||||||
@@ -118,7 +118,7 @@ exp:
|
|||||||
%%
|
%%
|
||||||
// Epilogue (C code).
|
// Epilogue (C code).
|
||||||
|
|
||||||
void yyerror (YYLTYPE *loc, const char *msg)
|
void yyerror (const YYLTYPE *loc, const char *msg)
|
||||||
{
|
{
|
||||||
YYLOCATION_PRINT (stderr, loc);
|
YYLOCATION_PRINT (stderr, loc);
|
||||||
fprintf (stderr, ": %s\n", msg);
|
fprintf (stderr, ": %s\n", msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user