Kaynağa Gözat

Allow empty initializer lists

pull/6/head
Max Brunsfeld 9 yıl önce
ebeveyn
işleme
be2676ed3e
3 değiştirilmiş dosya ile 26 ekleme ve 10 silme
  1. +3
    -2
      corpus/expressions.txt
  2. +4
    -2
      grammar.js
  3. +19
    -6
      src/grammar.json

+ 3
- 2
corpus/expressions.txt Dosyayı Görüntüle

@ -246,7 +246,7 @@ Compound literals
============================================
int main() {
x = (SomeType) { .f1 = 5, .f2 = 6 };
x = (SomeType) { .f1 = 5, .f2 = 6, .f3 = {} };
y = (struct SomeStruct) { 7, 8 };
}
@ -263,7 +263,8 @@ int main() {
(type_name (identifier))
(initializer_list
(designator (identifier)) (number_literal)
(designator (identifier)) (number_literal)))))
(designator (identifier)) (number_literal)
(designator (identifier)) (initializer_list)))))
(expression_statement (assignment_expression
(identifier)
(compound_literal_expression

+ 4
- 2
grammar.js Dosyayı Görüntüle

@ -549,8 +549,10 @@ module.exports = grammar({
initializer_list: $ => seq(
'{',
$._initializer_list_contents,
optional(','),
optional(seq(
$._initializer_list_contents,
optional(',')
)),
'}'
),

+ 19
- 6
src/grammar.json Dosyayı Görüntüle

@ -2736,16 +2736,29 @@
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "_initializer_list_contents"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_initializer_list_contents"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "BLANK"

Yükleniyor…
İptal
Kaydet