indent: classify 'inline' as a modifier rather than a word
This commit is contained in:
parent
3debcfbfeb
commit
27051cd2e2
|
@ -1,8 +1,9 @@
|
||||||
/* $NetBSD: lsym_storage_class.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */
|
/* $NetBSD: lsym_storage_class.c,v 1.5 2023/06/04 11:45:00 rillig Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tests for the token lsym_storage_class, which represents a storage class as
|
* Tests for the token lsym_modifier (formerly named lsym_storage_class), which
|
||||||
* part of a declaration.
|
* represents a type modifier such as 'const', a variable modifier such as a
|
||||||
|
* storage class, or a function modifier such as 'inline'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//indent input
|
//indent input
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: debug.c,v 1.28 2023/06/04 11:33:36 rillig Exp $ */
|
/* $NetBSD: debug.c,v 1.29 2023/06/04 11:45:00 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2023 The NetBSD Foundation, Inc.
|
* Copyright (c) 2023 The NetBSD Foundation, Inc.
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: debug.c,v 1.28 2023/06/04 11:33:36 rillig Exp $");
|
__RCSID("$NetBSD: debug.c,v 1.29 2023/06/04 11:45:00 rillig Exp $");
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ const char *const lsym_name[] = {
|
||||||
"comma",
|
"comma",
|
||||||
"semicolon",
|
"semicolon",
|
||||||
"typedef",
|
"typedef",
|
||||||
"storage_class",
|
"modifier",
|
||||||
"type_outside_parentheses",
|
"type_outside_parentheses",
|
||||||
"type_in_parentheses",
|
"type_in_parentheses",
|
||||||
"tag",
|
"tag",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: indent.c,v 1.320 2023/06/04 11:33:36 rillig Exp $ */
|
/* $NetBSD: indent.c,v 1.321 2023/06/04 11:45:00 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: indent.c,v 1.320 2023/06/04 11:33:36 rillig Exp $");
|
__RCSID("$NetBSD: indent.c,v 1.321 2023/06/04 11:45:00 rillig Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
@ -338,7 +338,7 @@ update_ps_decl_ptr(lexer_symbol lsym)
|
||||||
{
|
{
|
||||||
switch (ps.decl_ptr) {
|
switch (ps.decl_ptr) {
|
||||||
case dp_start:
|
case dp_start:
|
||||||
if (lsym == lsym_storage_class)
|
if (lsym == lsym_modifier)
|
||||||
ps.decl_ptr = dp_start;
|
ps.decl_ptr = dp_start;
|
||||||
else if (lsym == lsym_type_outside_parentheses)
|
else if (lsym == lsym_type_outside_parentheses)
|
||||||
ps.decl_ptr = dp_word;
|
ps.decl_ptr = dp_word;
|
||||||
|
@ -1187,7 +1187,7 @@ process_lsym(lexer_symbol lsym)
|
||||||
goto copy_token;
|
goto copy_token;
|
||||||
|
|
||||||
case lsym_typedef:
|
case lsym_typedef:
|
||||||
case lsym_storage_class:
|
case lsym_modifier:
|
||||||
goto copy_token;
|
goto copy_token;
|
||||||
|
|
||||||
case lsym_tag:
|
case lsym_tag:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: indent.h,v 1.165 2023/06/04 11:33:36 rillig Exp $ */
|
/* $NetBSD: indent.h,v 1.166 2023/06/04 11:45:00 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
@ -93,7 +93,7 @@ typedef enum lexer_symbol {
|
||||||
lsym_comma,
|
lsym_comma,
|
||||||
lsym_semicolon,
|
lsym_semicolon,
|
||||||
lsym_typedef,
|
lsym_typedef,
|
||||||
lsym_storage_class,
|
lsym_modifier, /* modifiers for types, functions, variables */
|
||||||
lsym_type_outside_parentheses,
|
lsym_type_outside_parentheses,
|
||||||
lsym_type_in_parentheses,
|
lsym_type_in_parentheses,
|
||||||
lsym_tag, /* 'struct', 'union' or 'enum' */
|
lsym_tag, /* 'struct', 'union' or 'enum' */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: lexi.c,v 1.208 2023/06/04 11:33:36 rillig Exp $ */
|
/* $NetBSD: lexi.c,v 1.209 2023/06/04 11:45:00 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: lexi.c,v 1.208 2023/06/04 11:33:36 rillig Exp $");
|
__RCSID("$NetBSD: lexi.c,v 1.209 2023/06/04 11:45:00 rillig Exp $");
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -47,7 +47,6 @@ __RCSID("$NetBSD: lexi.c,v 1.208 2023/06/04 11:33:36 rillig Exp $");
|
||||||
|
|
||||||
/* In lexi_alnum, this constant marks a type, independent of parentheses. */
|
/* In lexi_alnum, this constant marks a type, independent of parentheses. */
|
||||||
#define lsym_type lsym_type_outside_parentheses
|
#define lsym_type lsym_type_outside_parentheses
|
||||||
#define lsym_type_modifier lsym_storage_class
|
|
||||||
|
|
||||||
/* must be sorted alphabetically, is used in binary search */
|
/* must be sorted alphabetically, is used in binary search */
|
||||||
static const struct keyword {
|
static const struct keyword {
|
||||||
|
@ -57,43 +56,43 @@ static const struct keyword {
|
||||||
{"_Bool", lsym_type},
|
{"_Bool", lsym_type},
|
||||||
{"_Complex", lsym_type},
|
{"_Complex", lsym_type},
|
||||||
{"_Imaginary", lsym_type},
|
{"_Imaginary", lsym_type},
|
||||||
{"auto", lsym_storage_class},
|
{"auto", lsym_modifier},
|
||||||
{"bool", lsym_type},
|
{"bool", lsym_type},
|
||||||
{"break", lsym_word},
|
{"break", lsym_word},
|
||||||
{"case", lsym_case_label},
|
{"case", lsym_case_label},
|
||||||
{"char", lsym_type},
|
{"char", lsym_type},
|
||||||
{"complex", lsym_type},
|
{"complex", lsym_type},
|
||||||
{"const", lsym_type_modifier},
|
{"const", lsym_modifier},
|
||||||
{"continue", lsym_word},
|
{"continue", lsym_word},
|
||||||
{"default", lsym_case_label},
|
{"default", lsym_case_label},
|
||||||
{"do", lsym_do},
|
{"do", lsym_do},
|
||||||
{"double", lsym_type},
|
{"double", lsym_type},
|
||||||
{"else", lsym_else},
|
{"else", lsym_else},
|
||||||
{"enum", lsym_tag},
|
{"enum", lsym_tag},
|
||||||
{"extern", lsym_storage_class},
|
{"extern", lsym_modifier},
|
||||||
{"float", lsym_type},
|
{"float", lsym_type},
|
||||||
{"for", lsym_for},
|
{"for", lsym_for},
|
||||||
{"goto", lsym_word},
|
{"goto", lsym_word},
|
||||||
{"if", lsym_if},
|
{"if", lsym_if},
|
||||||
{"imaginary", lsym_type},
|
{"imaginary", lsym_type},
|
||||||
{"inline", lsym_word},
|
{"inline", lsym_modifier},
|
||||||
{"int", lsym_type},
|
{"int", lsym_type},
|
||||||
{"long", lsym_type},
|
{"long", lsym_type},
|
||||||
{"offsetof", lsym_offsetof},
|
{"offsetof", lsym_offsetof},
|
||||||
{"register", lsym_storage_class},
|
{"register", lsym_modifier},
|
||||||
{"restrict", lsym_word},
|
{"restrict", lsym_word},
|
||||||
{"return", lsym_return},
|
{"return", lsym_return},
|
||||||
{"short", lsym_type},
|
{"short", lsym_type},
|
||||||
{"signed", lsym_type},
|
{"signed", lsym_type},
|
||||||
{"sizeof", lsym_sizeof},
|
{"sizeof", lsym_sizeof},
|
||||||
{"static", lsym_storage_class},
|
{"static", lsym_modifier},
|
||||||
{"struct", lsym_tag},
|
{"struct", lsym_tag},
|
||||||
{"switch", lsym_switch},
|
{"switch", lsym_switch},
|
||||||
{"typedef", lsym_typedef},
|
{"typedef", lsym_typedef},
|
||||||
{"union", lsym_tag},
|
{"union", lsym_tag},
|
||||||
{"unsigned", lsym_type},
|
{"unsigned", lsym_type},
|
||||||
{"void", lsym_type},
|
{"void", lsym_type},
|
||||||
{"volatile", lsym_type_modifier},
|
{"volatile", lsym_modifier},
|
||||||
{"while", lsym_while}
|
{"while", lsym_while}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -254,7 +253,7 @@ lex_char_or_string(void)
|
||||||
static bool
|
static bool
|
||||||
probably_typename(void)
|
probably_typename(void)
|
||||||
{
|
{
|
||||||
if (ps.prev_token == lsym_storage_class)
|
if (ps.prev_token == lsym_modifier)
|
||||||
return true;
|
return true;
|
||||||
if (ps.block_init)
|
if (ps.block_init)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue