Sfoglia il codice sorgente

Fix parsing of char16_t, char32_t

pull/8/head
Max Brunsfeld 8 anni fa
parent
commit
a76daa432c
4 ha cambiato i file con 297 aggiunte e 220 eliminazioni
  1. +5
    -0
      corpus/types.txt
  2. +10
    -4
      grammar.js
  3. +95
    -39
      src/grammar.json
  4. +187
    -177
      src/parser.c

+ 5
- 0
corpus/types.txt Vedi File

@ -15,6 +15,9 @@ int32_t a;
int64_t a;
intptr_t a;
char16_t a;
char32_t a;
size_t a;
ssize_t a;
@ -33,6 +36,8 @@ ssize_t a;
(declaration (primitive_type) (identifier))
(declaration (primitive_type) (identifier))
(declaration (primitive_type) (identifier))
(declaration (primitive_type) (identifier))
(declaration (primitive_type) (identifier))
(declaration (primitive_type) (identifier)))
========================================

+ 10
- 4
grammar.js Vedi File

@ -347,16 +347,22 @@ module.exports = grammar({
))
),
primitive_type: $ => token(prec(1, choice(
primitive_type: $ => token(choice(
'bool',
'char',
'int',
'float',
'double',
'void',
/u?int(8|16|32|64|ptr)_t/,
/s?size_t/
))),
'size_t',
'ssize_t',
'intptr_t',
'uintptr_t',
'charptr_t',
...[8, 16, 32, 64].map(n => `int${n}_t`),
...[8, 16, 32, 64].map(n => `uint${n}_t`),
...[8, 16, 32, 64].map(n => `char${n}_t`)
)),
enum_specifier: $ => seq(
'enum',

+ 95
- 39
src/grammar.json Vedi File

@ -1645,45 +1645,101 @@
"primitive_type": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 1,
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "bool"
},
{
"type": "STRING",
"value": "char"
},
{
"type": "STRING",
"value": "int"
},
{
"type": "STRING",
"value": "float"
},
{
"type": "STRING",
"value": "double"
},
{
"type": "STRING",
"value": "void"
},
{
"type": "PATTERN",
"value": "u?int(8|16|32|64|ptr)_t"
},
{
"type": "PATTERN",
"value": "s?size_t"
}
]
}
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "bool"
},
{
"type": "STRING",
"value": "char"
},
{
"type": "STRING",
"value": "int"
},
{
"type": "STRING",
"value": "float"
},
{
"type": "STRING",
"value": "double"
},
{
"type": "STRING",
"value": "void"
},
{
"type": "STRING",
"value": "size_t"
},
{
"type": "STRING",
"value": "ssize_t"
},
{
"type": "STRING",
"value": "intptr_t"
},
{
"type": "STRING",
"value": "uintptr_t"
},
{
"type": "STRING",
"value": "charptr_t"
},
{
"type": "STRING",
"value": "int8_t"
},
{
"type": "STRING",
"value": "int16_t"
},
{
"type": "STRING",
"value": "int32_t"
},
{
"type": "STRING",
"value": "int64_t"
},
{
"type": "STRING",
"value": "uint8_t"
},
{
"type": "STRING",
"value": "uint16_t"
},
{
"type": "STRING",
"value": "uint32_t"
},
{
"type": "STRING",
"value": "uint64_t"
},
{
"type": "STRING",
"value": "char8_t"
},
{
"type": "STRING",
"value": "char16_t"
},
{
"type": "STRING",
"value": "char32_t"
},
{
"type": "STRING",
"value": "char64_t"
}
]
}
},
"enum_specifier": {

+ 187
- 177
src/parser.c
File diff soppresso perché troppo grande
Vedi File


Caricamento…
Annulla
Salva