Skip to content

Commit 829d550

Browse files
authored
Merge pull request hsutter#195 from jbatez/main
Consolidate grammar comments with parser logic.
2 parents 0a46d09 + 7b53ef0 commit 829d550

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

source/parse.h

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ auto violates_lifetime_safety = false;
3333
//
3434

3535
//G prefix-operator:
36-
//G one of '!'
36+
//G one of '!' '-' '+'
3737
//G
3838
auto is_prefix_operator(lexeme l) -> bool
3939
{
@@ -68,7 +68,7 @@ auto is_postfix_operator(lexeme l) -> bool
6868

6969

7070
//G assignment-operator:
71-
//G one of '=' '*=' '/=' '%=' '+=' '-=' '>>=' '<<='
71+
//G one of '=' '*=' '/=' '%=' '+=' '-=' '>>=' '<<=' '&=' '^=' '|='
7272
//G
7373
auto is_assignment_operator(lexeme l) -> bool
7474
{
@@ -1549,8 +1549,7 @@ class parser
15491549
return n;
15501550
}
15511551

1552-
if (curr().type() == lexeme::Identifier ||
1553-
curr().type() == lexeme::DecimalLiteral ||
1552+
if (curr().type() == lexeme::DecimalLiteral ||
15541553
curr().type() == lexeme::FloatLiteral ||
15551554
curr().type() == lexeme::StringLiteral ||
15561555
curr().type() == lexeme::CharacterLiteral ||
@@ -1944,7 +1943,7 @@ class parser
19441943

19451944
//G bit-xor-expression:
19461945
//G bit-and-expression
1947-
//G bit-xor-expression '&' bit-and-expression
1946+
//G bit-xor-expression '^' bit-and-expression
19481947
//G
19491948
auto bit_xor_expression(bool allow_angle_operators = true) {
19501949
return binary_expression<bit_xor_expression_node> (
@@ -1955,7 +1954,7 @@ class parser
19551954

19561955
//G bit-or-expression:
19571956
//G bit-xor-expression
1958-
//G bit-or-expression '&' bit-xor-expression
1957+
//G bit-or-expression '|' bit-xor-expression
19591958
//G
19601959
auto bit_or_expression(bool allow_angle_operators = true) {
19611960
return binary_expression<bit_or_expression_node> (
@@ -1990,7 +1989,7 @@ class parser
19901989

19911990
//G assignment-expression:
19921991
//G logical-or-expression
1993-
//G assignment-expression assignment-operator assignment-expression
1992+
//G assignment-expression assignment-operator logical-or-expression
19941993
//G
19951994
auto assignment_expression(bool allow_angle_operators = true) -> std::unique_ptr<assignment_expression_node> {
19961995
//return binary_expression<assignment_expression_node> (
@@ -2037,7 +2036,7 @@ class parser
20372036

20382037
//G expression-list:
20392038
//G parameter-direction? expression
2040-
//G expression-list ',' expression
2039+
//G expression-list ',' parameter-direction? expression
20412040
//G
20422041
auto expression_list(token const* open_paren, bool inside_initializer = false) -> std::unique_ptr<expression_list_node> {
20432042
auto pass = passing_style::in;
@@ -2078,6 +2077,10 @@ class parser
20782077
pass = passing_style::move;
20792078
next();
20802079
}
2080+
else if (curr().type() == lexeme::Identifier && curr() == "forward") {
2081+
pass = passing_style::forward;
2082+
next();
2083+
}
20812084
auto expr = expression();
20822085
if (!expr) {
20832086
error("invalid text in expression list");
@@ -2128,12 +2131,6 @@ class parser
21282131
n->id = std::move(id);
21292132
assert (n->id.index() == type_id_node::unqualified);
21302133
}
2131-
else if (curr().type() == lexeme::Keyword || curr().type() == lexeme::Cpp2FixedType) {
2132-
n->pos = curr().position();
2133-
n->id = &curr();
2134-
next();
2135-
assert (n->id.index() == type_id_node::keyword);
2136-
}
21372134
else {
21382135
if (!n->pc_qualifiers.empty()) {
21392136
error("'*'/'const' type qualifiers must be followed by a type name or '_' wildcard");
@@ -2939,7 +2936,7 @@ class parser
29392936

29402937

29412938
//G parameter-declaration:
2942-
//G parameter-direction? declaration
2939+
//G parameter-direction? this-specifier? declaration
29432940
//G
29442941
//G parameter-direction: one of
29452942
//G 'in' 'copy' 'inout' 'out' 'move' 'forward'

0 commit comments

Comments
 (0)