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:
Akim Demaille
2021-02-09 07:01:00 +01:00
parent e0ab5c324a
commit f50fff58d1
3 changed files with 12 additions and 12 deletions

View File

@@ -87,7 +87,7 @@
yytoken_kind_t
yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc,
const user_context *uctx);
void yyerror (YYLTYPE *loc, const user_context *uctx,
void yyerror (const YYLTYPE *loc, const user_context *uctx,
char const *format, ...)
__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.
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)
return;

View File

@@ -68,8 +68,8 @@
static void node_print (FILE *, const Node *);
static Node *stmtMerge (YYSTYPE x0, YYSTYPE x1);
static void yyerror (YYLTYPE const * const llocp, const char *msg);
static yytoken_kind_t yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
static void yyerror (YYLTYPE const * const loc, const char *msg);
static yytoken_kind_t yylex (YYSTYPE *lval, YYLTYPE *lloc);
}
%expect-rr 1
@@ -138,7 +138,7 @@ yyerror (YYLTYPE const * const loc, const char *msg)
FILE * input = NULL;
yytoken_kind_t
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
yylex (YYSTYPE *lval, YYLTYPE *lloc)
{
static int lineNum = 1;
static int colNum = 0;
@@ -165,8 +165,8 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
default:
{
yytoken_kind_t tok;
llocp->first_line = llocp->last_line = lineNum;
llocp->first_column = colNum;
lloc->first_line = lloc->last_line = lineNum;
lloc->first_column = colNum;
if (isalpha (c))
{
char buffer[256];
@@ -186,12 +186,12 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
if (isupper ((unsigned char) buffer[0]))
{
tok = TYPENAME;
lvalp->TYPENAME = new_term (strcpy (malloc (i), buffer));
lval->TYPENAME = new_term (strcpy (malloc (i), buffer));
}
else
{
tok = ID;
lvalp->ID = new_term (strcpy (malloc (i), buffer));
lval->ID = new_term (strcpy (malloc (i), buffer));
}
}
else
@@ -199,7 +199,7 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
colNum += 1;
tok = c;
}
llocp->last_column = colNum;
lloc->last_column = colNum;
return tok;
}
}

View File

@@ -28,7 +28,7 @@
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc)
YY_DECL;
void yyerror (YYLTYPE *loc, const char *msg);
void yyerror (const YYLTYPE *loc, const char *msg);
}
// Emitted on top of the implementation file.
@@ -118,7 +118,7 @@ exp:
%%
// Epilogue (C code).
void yyerror (YYLTYPE *loc, const char *msg)
void yyerror (const YYLTYPE *loc, const char *msg)
{
YYLOCATION_PRINT (stderr, loc);
fprintf (stderr, ": %s\n", msg);