Skip to content

Commit 9585ecc

Browse files
committed
Minor grammar and clean-compile tidying
Make grammar productions all <90 characters (they mostly were anyway, and some long names just weren't needed) I changed some that ended in _-list_ to just end in _s_ (for plural), but left some like _expression-list_ because they were already short and read better with a dash (I think _expression-list_ reads better than _expressions_, YMMV) Also added `-Wno-error=dangling-reference` to avoid a false positive in GCC 13; see #818 (comment)
1 parent 30c892a commit 9585ecc

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

.github/workflows/build-cppfront.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
runs-on: ${{ matrix.runs-on }}
4343
env:
4444
CXX: ${{ matrix.compiler }}
45-
CXXFLAGS: -std=${{ matrix.cxx-std }} -Wall -Wextra -Wold-style-cast -Wunused-parameter -Wpedantic -Werror -pthread
45+
CXXFLAGS: -std=${{ matrix.cxx-std }} -Wall -Wextra -Wold-style-cast -Wunused-parameter -Wno-error=dangling-reference -Wpedantic -Werror -pthread
4646
steps:
4747
- uses: actions/checkout@v3
4848
- name: Install compiler

source/lex.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,11 @@ auto lex_line(
872872
};
873873

874874
//G universal-character-name:
875-
//G '\u' hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
876-
//G '\U' hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
875+
//G '\u' hex-quad
876+
//G '\U' hex-quad hex-quad
877+
//G
878+
//G hex-quad:
879+
//G hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
877880
//G
878881
auto peek_is_universal_character_name = [&](colno_t offset)
879882
{
@@ -1506,7 +1509,7 @@ auto lex_line(
15061509
//G decimal-literal ''' digit [uU][lL][lL]
15071510
//G
15081511
//G floating-point-literal:
1509-
//G digit { ' | digit }* . digit ({ ' | digit }*)? ([eE][-+]?digit { ' | digit }*) [fFlL]
1512+
//G digit { ''' | digit }* . digit ({ ''' | digit }*)? ([eE][-+]?digit { ' | digit }*) [fFlL]
15101513
//G
15111514
//G TODO full grammar & refactor to utility functions with their
15121515
//G own unit test rather than inline everything here

source/parse.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6334,13 +6334,13 @@ class parser
63346334
//G is-as-expression as-type-cast
63356335
//GTODO type-id is-type-constraint
63366336
//G
6337-
//G is-type-constraint
6337+
//G is-type-constraint:
63386338
//G 'is' type-id
63396339
//G
6340-
//G is-value-constraint
6340+
//G is-value-constraint:
63416341
//G 'is' expression
63426342
//G
6343-
//G as-type-cast
6343+
//G as-type-cast:
63446344
//G 'as' type-id
63456345
//G
63466346
auto is_as_expression()
@@ -6424,10 +6424,10 @@ class parser
64246424
//G ...
64256425
//G
64266426
//G template-id:
6427-
//G identifier '<' template-argument-list? '>'
6427+
//G identifier '<' template-arguments? '>'
64286428
//G
6429-
//G template-argument-list:
6430-
//G template-argument-list ',' template-argument
6429+
//G template-arguments:
6430+
//G template-arguments ',' template-argument
64316431
//G
64326432
//G template-argument:
64336433
//G # note: < > << >> are not allowed in expressions until new ( is opened
@@ -6456,7 +6456,7 @@ class parser
64566456
one_past_identifier_end_pos.colno += curr().length();
64576457
next();
64586458

6459-
// Handle the template-argument-list if there is one
6459+
// Handle the template-arguments if there is one
64606460
if (
64616461
curr().type() == lexeme::Less
64626462
&& curr().position() == one_past_identifier_end_pos
@@ -7281,7 +7281,7 @@ class parser
72817281
//G declaration
72827282
//G expression-statement
72837283
//G
7284-
//G contract-statement
7284+
//G contract-statement:
72857285
//G contract ';'
72867286
//
72877287
//GTODO try-block
@@ -7656,7 +7656,7 @@ class parser
76567656
}
76577657

76587658

7659-
//G parameter-declaration-list
7659+
//G parameter-declaration-list:
76607660
//G '(' parameter-declaration-seq? ')'
76617661
//G
76627662
//G parameter-declaration-seq:
@@ -8004,22 +8004,22 @@ class parser
80048004

80058005

80068006
//G unnamed-declaration:
8007-
//G ':' meta-functions-list? template-parameter-declaration-list? function-type requires-clause? '=' statement
8008-
//G ':' meta-functions-list? template-parameter-declaration-list? function-type statement
8009-
//G ':' meta-functions-list? template-parameter-declaration-list? type-id? requires-clause? '=' statement
8010-
//G ':' meta-functions-list? template-parameter-declaration-list? type-id
8011-
//G ':' meta-functions-list? template-parameter-declaration-list? 'final'? 'type' requires-clause? '=' statement
8007+
//G ':' meta-functions? template-parameters? function-type requires-clause? '=' statement
8008+
//G ':' meta-functions? template-parameters? function-type statement
8009+
//G ':' meta-functions? template-parameters? type-id? requires-clause? '=' statement
8010+
//G ':' meta-functions? template-parameters? type-id
8011+
//G ':' meta-functions? template-parameters? 'final'? 'type' requires-clause? '=' statement
80128012
//G ':' 'namespace' '=' statement
80138013
//G
8014-
//G meta-functions-list:
8014+
//G meta-functions:
80158015
//G '@' id-expression
8016-
//G meta-functions-list '@' id-expression
8016+
//G meta-functions '@' id-expression
80178017
//G
80188018
//G requires-clause:
80198019
//G # note: for aliases, == is not allowed in expressions until new ( is opened
80208020
//G 'requires' logical-or-expression
80218021
//G
8022-
//G template-parameter-declaration-list
8022+
//G template-parameters:
80238023
//G '<' parameter-declaration-seq '>'
80248024
//G
80258025
auto unnamed_declaration(
@@ -8527,9 +8527,9 @@ class parser
85278527

85288528

85298529
//G alias:
8530-
//G ':' template-parameter-declaration-list? 'type' requires-clause? '==' type-id ';'
8530+
//G ':' template-parameters? 'type' requires-clause? '==' type-id ';'
85318531
//G ':' 'namespace' '==' id-expression ';'
8532-
//G ':' template-parameter-declaration-list? type-id? requires-clause? '==' expression ';'
8532+
//G ':' template-parameters? type-id? requires-clause? '==' expression ';'
85338533
//G
85348534
//GT ':' function-type '==' expression ';'
85358535
//GT # See commit 63efa6ed21c4d4f4f136a7a73e9f6b2c110c81d7 comment

0 commit comments

Comments
 (0)