Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: indent grammar using tabs instead ...
details: https://anonhg.NetBSD.org/src/rev/62a4f3a13a4d
branches: trunk
changeset: 377454:62a4f3a13a4d
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Jul 12 13:00:09 2023 +0000
description:
lint: indent grammar using tabs instead of spaces
Manually indenting the grammar rules using two spaces was too
cumbersome.
diffstat:
usr.bin/xlint/lint1/cgram.y | 1610 +++++++++++++++++++++---------------------
1 files changed, 805 insertions(+), 805 deletions(-)
diffs (truncated from 2573 to 300 lines):
diff -r ba8ced882b6f -r 62a4f3a13a4d usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Wed Jul 12 12:50:46 2023 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Wed Jul 12 13:00:09 2023 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.454 2023/07/11 21:13:36 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.455 2023/07/12 13:00:09 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.454 2023/07/11 21:13:36 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.455 2023/07/12 13:00:09 rillig Exp $");
#endif
#include <limits.h>
@@ -425,7 +425,7 @@ is_either(const char *s, const char *a,
%%
program:
- /* empty */ {
+ /* empty */ {
/* TODO: Make this an error in C99 mode as well. */
if (!allow_trad && !allow_c99) {
/* empty translation unit */
@@ -434,43 +434,43 @@ program:
/* empty translation unit */
warning(272);
}
- }
- | translation_unit
- ;
+ }
+| translation_unit
+;
identifier_sym: /* helper for struct/union/enum */
- identifier {
+ identifier {
$$ = getsym($1);
- }
- ;
+ }
+;
/* K&R ???, C90 ???, C99 6.4.2.1, C11 ??? */
identifier:
- T_NAME {
+ T_NAME {
debug_step("cgram: name '%s'", $1->sb_name);
$$ = $1;
- }
- | T_TYPENAME {
+ }
+| T_TYPENAME {
debug_step("cgram: typename '%s'", $1->sb_name);
$$ = $1;
- }
- ;
+ }
+;
/* see C99 6.4.5, string literals are joined by 5.1.1.2 */
string:
- T_STRING
- | string T_STRING {
+ T_STRING
+| string T_STRING {
if (!allow_c90) {
/* concatenated strings are illegal in traditional C */
warning(219);
}
$$ = cat_strings($1, $2);
- }
- ;
+ }
+;
/* K&R 7.1, C90 ???, C99 6.5.1, C11 6.5.1 */
primary_expression:
- T_NAME {
+ T_NAME {
bool sys_name, sys_next;
sys_name = in_system_header;
if (yychar < 0)
@@ -479,102 +479,102 @@ primary_expression:
in_system_header = sys_name;
$$ = build_name(getsym($1), yychar == T_LPAREN);
in_system_header = sys_next;
- }
- | T_CON {
+ }
+| T_CON {
$$ = build_constant(gettyp($1->v_tspec), $1);
- }
- | string {
+ }
+| string {
$$ = build_string($1);
- }
- | T_LPAREN expression T_RPAREN {
+ }
+| T_LPAREN expression T_RPAREN {
if ($2 != NULL)
$2->tn_parenthesized = true;
$$ = $2;
- }
- | generic_selection
+ }
+| generic_selection
/* GCC primary-expression, see c_parser_postfix_expression */
/* TODO: C99 7.17p3 allows not only an identifier but a designator. */
- | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN {
+| T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN {
set_symtyp(FMEMBER);
$$ = build_offsetof($3, getsym($5));
- }
- ;
+ }
+;
/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */
generic_selection:
- T_GENERIC T_LPAREN assignment_expression T_COMMA
+ T_GENERIC T_LPAREN assignment_expression T_COMMA
generic_assoc_list T_RPAREN {
/* generic selection requires C11 or later */
c11ism(345);
$$ = build_generic_selection($3, $5);
- }
- ;
+ }
+;
/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */
generic_assoc_list:
- generic_association
- | generic_assoc_list T_COMMA generic_association {
+ generic_association
+| generic_assoc_list T_COMMA generic_association {
$3->ga_prev = $1;
$$ = $3;
- }
- ;
+ }
+;
/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */
generic_association:
- type_name T_COLON assignment_expression {
+ type_name T_COLON assignment_expression {
$$ = block_zero_alloc(sizeof(*$$));
$$->ga_arg = $1;
$$->ga_result = $3;
- }
- | T_DEFAULT T_COLON assignment_expression {
+ }
+| T_DEFAULT T_COLON assignment_expression {
$$ = block_zero_alloc(sizeof(*$$));
$$->ga_arg = NULL;
$$->ga_result = $3;
- }
- ;
+ }
+;
/* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2, C23 6.5.2 */
postfix_expression:
- primary_expression
- | postfix_expression T_LBRACK sys expression T_RBRACK {
+ primary_expression
+| postfix_expression T_LBRACK sys expression T_RBRACK {
$$ = build_unary(INDIR, $3, build_binary($1, PLUS, $3, $4));
- }
- | postfix_expression T_LPAREN sys T_RPAREN {
+ }
+| postfix_expression T_LPAREN sys T_RPAREN {
$$ = build_function_call($1, $3, NULL);
- }
- | postfix_expression T_LPAREN sys argument_expression_list T_RPAREN {
+ }
+| postfix_expression T_LPAREN sys argument_expression_list T_RPAREN {
$$ = build_function_call($1, $3, $4);
- }
- | postfix_expression point_or_arrow sys T_NAME {
+ }
+| postfix_expression point_or_arrow sys T_NAME {
$$ = build_member_access($1, $2, $3, $4);
- }
- | postfix_expression T_INCDEC sys {
+ }
+| postfix_expression T_INCDEC sys {
$$ = build_unary($2 == INC ? INCAFT : DECAFT, $3, $1);
- }
- | T_LPAREN type_name T_RPAREN { /* C99 6.5.2.5 "Compound literals" */
+ }
+| T_LPAREN type_name T_RPAREN { /* C99 6.5.2.5 "Compound literals" */
sym_t *tmp = mktempsym($2);
begin_initialization(tmp);
cgram_declare(tmp, true, NULL);
- } braced_initializer {
+ } braced_initializer {
if (!allow_c99)
/* compound literals are a C99/GCC extension */
gnuism(319);
$$ = build_name(current_initsym(), false);
end_initialization();
- }
- | T_LPAREN compound_statement_lbrace {
+ }
+| T_LPAREN compound_statement_lbrace {
begin_statement_expr();
- } gcc_statement_expr_list {
+ } gcc_statement_expr_list {
do_statement_expr($4);
- } compound_statement_rbrace T_RPAREN {
+ } compound_statement_rbrace T_RPAREN {
$$ = end_statement_expr();
- }
- ;
+ }
+;
comma_opt: /* helper for 'postfix_expression' */
- /* empty */
- | T_COMMA
- ;
+ /* empty */
+| T_COMMA
+;
/*
* The inner part of a GCC statement-expression of the form ({ ... }).
@@ -582,26 +582,26 @@ comma_opt: /* helper for 'postfix_expr
* https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
*/
gcc_statement_expr_list:
- gcc_statement_expr_item
- | gcc_statement_expr_list gcc_statement_expr_item {
+ gcc_statement_expr_item
+| gcc_statement_expr_list gcc_statement_expr_item {
$$ = $2;
- }
- ;
+ }
+;
gcc_statement_expr_item:
- declaration_or_error {
+ declaration_or_error {
clear_warning_flags();
$$ = NULL;
- }
- | non_expr_statement {
+ }
+| non_expr_statement {
$$ = expr_alloc_tnode();
$$->tn_type = gettyp(VOID);
- }
- | T_SEMI {
+ }
+| T_SEMI {
$$ = expr_alloc_tnode();
$$->tn_type = gettyp(VOID);
- }
- | expression T_SEMI {
+ }
+| expression T_SEMI {
if ($1 == NULL) { /* in case of syntax errors */
$$ = expr_alloc_tnode();
$$->tn_type = gettyp(VOID);
@@ -613,102 +613,102 @@ gcc_statement_expr_item:
seen_fallthrough = false;
$$ = $1;
}
- }
- ;
+ }
+;
point_or_arrow: /* helper for 'postfix_expression' */
- T_POINT {
+ T_POINT {
set_symtyp(FMEMBER);
$$ = POINT;
- }
- | T_ARROW {
+ }
+| T_ARROW {
set_symtyp(FMEMBER);
$$ = ARROW;
- }
- ;
+ }
+;
/* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */
Home |
Main Index |
Thread Index |
Old Index