Browse Source

Merge pull request #72 from tjdevries/tjdevries/add_compound_statement_to_call_expression

fix: add compound statement to call expression
pull/115/head
Amaan Qureshi 3 years ago
committed by GitHub
parent
commit
618018069b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43647 additions and 43434 deletions
  1. +1
    -1
      grammar.js
  2. +22
    -4
      src/grammar.json
  3. +4
    -0
      src/node-types.json
  4. +43574
    -43429
      src/parser.c
  5. +46
    -0
      test/corpus/expressions.txt

+ 1
- 1
grammar.js View File

@ -969,7 +969,7 @@ module.exports = grammar({
commaSep(field('label', $.identifier)),
),
argument_list: $ => seq('(', commaSep($._expression), ')'),
argument_list: $ => seq('(', commaSep(choice($._expression, $.compound_statement)), ')'),
field_expression: $ => seq(
prec(PREC.FIELD, seq(

+ 22
- 4
src/grammar.json View File

@ -6193,8 +6193,17 @@
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "SYMBOL",
"name": "compound_statement"
}
]
},
{
"type": "REPEAT",
@ -6206,8 +6215,17 @@
"value": ","
},
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "SYMBOL",
"name": "compound_statement"
}
]
}
]
}

+ 4
- 0
src/node-types.json View File

@ -428,6 +428,10 @@
"type": "_expression",
"named": true
},
{
"type": "compound_statement",
"named": true
},
{
"type": "preproc_defined",
"named": true

+ 43574
- 43429
src/parser.c
File diff suppressed because it is too large
View File


+ 46
- 0
test/corpus/expressions.txt View File

@ -205,6 +205,52 @@ asm volatile (
(string_literal
(string_content))))))
================================================================================
Function call with compound statement
================================================================================
#define TAKES_BLOCK(x, block) for (i = 0; i < x; i++) block
int main(void) {
{
int x = 0;
}
TAKES_BLOCK(10, {
// Doesn't matter what I put in here
});
}
--------------------------------------------------------------------------------
(translation_unit
(preproc_function_def
(identifier)
(preproc_params
(identifier)
(identifier))
(preproc_arg))
(function_definition
(primitive_type)
(function_declarator
(identifier)
(parameter_list
(parameter_declaration
(primitive_type))))
(compound_statement
(compound_statement
(declaration
(primitive_type)
(init_declarator
(identifier)
(number_literal))))
(expression_statement
(call_expression
(identifier)
(argument_list
(number_literal)
(compound_statement
(comment))))))))
================================================================================
String literals
================================================================================

Loading…
Cancel
Save