Skip to content

Commit

Permalink
Minor grammar and clean-compile tidying
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
hsutter committed Jan 4, 2024
1 parent 30c892a commit 9585ecc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-cppfront.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
runs-on: ${{ matrix.runs-on }}
env:
CXX: ${{ matrix.compiler }}
CXXFLAGS: -std=${{ matrix.cxx-std }} -Wall -Wextra -Wold-style-cast -Wunused-parameter -Wpedantic -Werror -pthread
CXXFLAGS: -std=${{ matrix.cxx-std }} -Wall -Wextra -Wold-style-cast -Wunused-parameter -Wno-error=dangling-reference -Wpedantic -Werror -pthread
steps:
- uses: actions/checkout@v3
- name: Install compiler
Expand Down
9 changes: 6 additions & 3 deletions source/lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,11 @@ auto lex_line(
};

//G universal-character-name:
//G '\u' hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
//G '\U' hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
//G '\u' hex-quad
//G '\U' hex-quad hex-quad
//G
//G hex-quad:
//G hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
//G
auto peek_is_universal_character_name = [&](colno_t offset)
{
Expand Down Expand Up @@ -1506,7 +1509,7 @@ auto lex_line(
//G decimal-literal ''' digit [uU][lL][lL]
//G
//G floating-point-literal:
//G digit { ' | digit }* . digit ({ ' | digit }*)? ([eE][-+]?digit { ' | digit }*) [fFlL]
//G digit { ''' | digit }* . digit ({ ''' | digit }*)? ([eE][-+]?digit { ' | digit }*) [fFlL]
//G
//G TODO full grammar & refactor to utility functions with their
//G own unit test rather than inline everything here
Expand Down
38 changes: 19 additions & 19 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -6334,13 +6334,13 @@ class parser
//G is-as-expression as-type-cast
//GTODO type-id is-type-constraint
//G
//G is-type-constraint
//G is-type-constraint:
//G 'is' type-id
//G
//G is-value-constraint
//G is-value-constraint:
//G 'is' expression
//G
//G as-type-cast
//G as-type-cast:
//G 'as' type-id
//G
auto is_as_expression()
Expand Down Expand Up @@ -6424,10 +6424,10 @@ class parser
//G ...
//G
//G template-id:
//G identifier '<' template-argument-list? '>'
//G identifier '<' template-arguments? '>'
//G
//G template-argument-list:
//G template-argument-list ',' template-argument
//G template-arguments:
//G template-arguments ',' template-argument
//G
//G template-argument:
//G # note: < > << >> are not allowed in expressions until new ( is opened
Expand Down Expand Up @@ -6456,7 +6456,7 @@ class parser
one_past_identifier_end_pos.colno += curr().length();
next();

// Handle the template-argument-list if there is one
// Handle the template-arguments if there is one
if (
curr().type() == lexeme::Less
&& curr().position() == one_past_identifier_end_pos
Expand Down Expand Up @@ -7281,7 +7281,7 @@ class parser
//G declaration
//G expression-statement
//G
//G contract-statement
//G contract-statement:
//G contract ';'
//
//GTODO try-block
Expand Down Expand Up @@ -7656,7 +7656,7 @@ class parser
}


//G parameter-declaration-list
//G parameter-declaration-list:
//G '(' parameter-declaration-seq? ')'
//G
//G parameter-declaration-seq:
Expand Down Expand Up @@ -8004,22 +8004,22 @@ class parser


//G unnamed-declaration:
//G ':' meta-functions-list? template-parameter-declaration-list? function-type requires-clause? '=' statement
//G ':' meta-functions-list? template-parameter-declaration-list? function-type statement
//G ':' meta-functions-list? template-parameter-declaration-list? type-id? requires-clause? '=' statement
//G ':' meta-functions-list? template-parameter-declaration-list? type-id
//G ':' meta-functions-list? template-parameter-declaration-list? 'final'? 'type' requires-clause? '=' statement
//G ':' meta-functions? template-parameters? function-type requires-clause? '=' statement
//G ':' meta-functions? template-parameters? function-type statement
//G ':' meta-functions? template-parameters? type-id? requires-clause? '=' statement
//G ':' meta-functions? template-parameters? type-id
//G ':' meta-functions? template-parameters? 'final'? 'type' requires-clause? '=' statement
//G ':' 'namespace' '=' statement
//G
//G meta-functions-list:
//G meta-functions:
//G '@' id-expression
//G meta-functions-list '@' id-expression
//G meta-functions '@' id-expression
//G
//G requires-clause:
//G # note: for aliases, == is not allowed in expressions until new ( is opened
//G 'requires' logical-or-expression
//G
//G template-parameter-declaration-list
//G template-parameters:
//G '<' parameter-declaration-seq '>'
//G
auto unnamed_declaration(
Expand Down Expand Up @@ -8527,9 +8527,9 @@ class parser


//G alias:
//G ':' template-parameter-declaration-list? 'type' requires-clause? '==' type-id ';'
//G ':' template-parameters? 'type' requires-clause? '==' type-id ';'
//G ':' 'namespace' '==' id-expression ';'
//G ':' template-parameter-declaration-list? type-id? requires-clause? '==' expression ';'
//G ':' template-parameters? type-id? requires-clause? '==' expression ';'
//G
//GT ':' function-type '==' expression ';'
//GT # See commit 63efa6ed21c4d4f4f136a7a73e9f6b2c110c81d7 comment
Expand Down

0 comments on commit 9585ecc

Please sign in to comment.