Skip to content

Commit

Permalink
Handle postfix type qualifiers in compound literals
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunsfeld committed Apr 18, 2019
1 parent 79930c4 commit 175d93b
Show file tree
Hide file tree
Showing 4 changed files with 27,932 additions and 27,846 deletions.
9 changes: 8 additions & 1 deletion corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ int main() {
7,
8
};
z = (char const []) {'a', 'b'};
}

---
Expand Down Expand Up @@ -374,7 +375,13 @@ int main() {
(type_descriptor (struct_specifier (type_identifier)))
(initializer_list
(number_literal)
(number_literal))))))))
(number_literal)))))
(expression_statement
(assignment_expression
(identifier)
(compound_literal_expression
(type_descriptor (primitive_type) (type_qualifier) (abstract_array_declarator))
(initializer_list (char_literal) (char_literal))))))))

============================================
Compound literals with trailing commas
Expand Down
1 change: 1 addition & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ module.exports = grammar({
type_descriptor: $ => seq(
repeat($.type_qualifier),
$._type_specifier,
repeat($.type_qualifier),
optional($._abstract_declarator)
),

Expand Down
7 changes: 7 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3399,6 +3399,13 @@
"type": "SYMBOL",
"name": "_type_specifier"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "type_qualifier"
}
},
{
"type": "CHOICE",
"members": [
Expand Down
Loading

0 comments on commit 175d93b

Please sign in to comment.