diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2021-02-09 07:01:00 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2021-02-09 07:04:05 +0100 |
commit | f50fff58d10a029799fd9d62b1a52fb98119b6ee (patch) | |
tree | a7beb8eba60b95044fcd46c4907f6529b7cbd4c6 /examples | |
parent | e0ab5c324aaf7d04788eb380c93da0390ee337e5 (diff) | |
download | bison-f50fff58d10a029799fd9d62b1a52fb98119b6ee.tar.gz |
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.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/c/bistromathic/parse.y | 4 | ||||
-rw-r--r-- | examples/c/glr/c++-types.y | 16 | ||||
-rw-r--r-- | examples/c/lexcalc/parse.y | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/examples/c/bistromathic/parse.y b/examples/c/bistromathic/parse.y index e10d99ce..e06db523 100644 --- a/examples/c/bistromathic/parse.y +++ b/examples/c/bistromathic/parse.y @@ -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; diff --git a/examples/c/glr/c++-types.y b/examples/c/glr/c++-types.y index a96ef70c..67cadcaf 100644 --- a/examples/c/glr/c++-types.y +++ b/examples/c/glr/c++-types.y @@ -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; } } diff --git a/examples/c/lexcalc/parse.y b/examples/c/lexcalc/parse.y index 9c137b58..aa72a410 100644 --- a/examples/c/lexcalc/parse.y +++ b/examples/c/lexcalc/parse.y @@ -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); |