Selaa lähdekoodia

feat: add _Generic expressions and missing type qualifiers

_Generic is a C11 feature, __restrict__ and _Noreturn were added to type_qualifiers
pull/137/head
Amaan Qureshi 3 vuotta sitten
vanhempi
commit
20fee37fd0
No known key found for this signature in database GPG Key ID: E67890ADC4227273
1 muutettua tiedostoa jossa 12 lisäystä ja 0 poistoa
  1. +12
    -0
      grammar.js

+ 12
- 0
grammar.js Näytä tiedosto

@ -475,7 +475,9 @@ module.exports = grammar({
'const',
'volatile',
'restrict',
'__restrict__',
'_Atomic',
'_Noreturn',
),
_type_specifier: $ => choice(
@ -736,6 +738,7 @@ module.exports = grammar({
$.cast_expression,
$.pointer_expression,
$.sizeof_expression,
$.generic_expression,
$.subscript_expression,
$.call_expression,
$.field_expression,
@ -865,6 +868,15 @@ module.exports = grammar({
),
)),
generic_expression: $ => prec(PREC.CALL, seq(
'_Generic',
'(',
$._expression,
',',
commaSep1(seq($.type_descriptor, ':', $._expression)),
')',
)),
subscript_expression: $ => prec(PREC.SUBSCRIPT, seq(
field('argument', $._expression),
'[',

Ladataan…
Peruuta
Tallenna