Max Brunsfeld 7 年之前
父節點
當前提交
ed56d5e288
共有 4 個文件被更改,包括 28320 次插入28548 次删除
  1. +19
    -0
      corpus/declarations.txt
  2. +8
    -8
      grammar.js
  3. +64
    -48
      src/grammar.json
  4. +28229
    -28492
      src/parser.c

+ 19
- 0
corpus/declarations.txt 查看文件

@ -313,3 +313,22 @@ volatile int z = 7;
(type_qualifier)
(primitive_type)
(init_declarator (identifier) (number_literal))))
================================
Local array declarations
================================
int main() {
char the_buffer[the_size];
char the_other_buffer[*];
}
---
(translation_unit
(function_definition
(primitive_type)
(function_declarator (identifier) (parameter_list))
(compound_statement
(declaration (primitive_type) (array_declarator (identifier) (identifier)))
(declaration (primitive_type) (array_declarator (identifier))))))

+ 8
- 8
grammar.js 查看文件

@ -216,29 +216,29 @@ module.exports = grammar({
array_declarator: $ => prec(1, seq(
$._declarator,
'[',
optional($._declaration_specifiers),
optional($._expression),
repeat($.type_qualifier),
optional(choice($._expression, '*')),
']'
)),
array_field_declarator: $ => prec(1, seq(
$._field_declarator,
'[',
optional($._declaration_specifiers),
optional($._expression),
repeat($.type_qualifier),
optional(choice($._expression, '*')),
']'
)),
array_type_declarator: $ => prec(1, seq(
$._type_declarator,
'[',
optional($._declaration_specifiers),
optional($._expression),
repeat($.type_qualifier),
optional(choice($._expression, '*')),
']'
)),
abstract_array_declarator: $ => prec(1, seq(
optional($._abstract_declarator),
'[',
optional($._declaration_specifiers),
optional($._expression),
repeat($.type_qualifier),
optional(choice($._expression, '*')),
']'
)),

+ 64
- 48
src/grammar.json 查看文件

@ -1574,23 +1574,27 @@
"value": "["
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_declaration_specifiers"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "type_qualifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "STRING",
"value": "*"
}
]
},
{
"type": "BLANK"
@ -1619,23 +1623,27 @@
"value": "["
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_declaration_specifiers"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "type_qualifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "STRING",
"value": "*"
}
]
},
{
"type": "BLANK"
@ -1664,23 +1672,27 @@
"value": "["
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_declaration_specifiers"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "type_qualifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "STRING",
"value": "*"
}
]
},
{
"type": "BLANK"
@ -1717,23 +1729,27 @@
"value": "["
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_declaration_specifiers"
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "type_qualifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "STRING",
"value": "*"
}
]
},
{
"type": "BLANK"

+ 28229
- 28492
src/parser.c
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存