Przeglądaj źródła

#include can be followed by a macro name or a macro call (#38)

* #include can be followed by a macro name or a macro call

* In preproc_include, use preproc_call_expression
pull/37/head
calixteman 6 lat temu
committed by Max Brunsfeld
rodzic
commit
c455818961
5 zmienionych plików z 31324 dodań i 31799 usunięć
  1. +7
    -1
      grammar.js
  2. +17
    -0
      src/grammar.json
  3. +8
    -0
      src/node-types.json
  4. +31284
    -31797
      src/parser.c
  5. +8
    -1
      test/corpus/preprocessor.txt

+ 7
- 1
grammar.js Wyświetl plik

@ -71,7 +71,13 @@ module.exports = grammar({
preproc_include: $ => seq(
preprocessor('include'),
field('path', choice($.string_literal, $.system_lib_string))
field('path', choice(
$.string_literal,
$.system_lib_string,
$.identifier,
alias($.preproc_call_expression, $.call_expression),
)),
'\n'
),
preproc_def: $ => seq(

+ 17
- 0
src/grammar.json Wyświetl plik

@ -87,9 +87,26 @@
{
"type": "SYMBOL",
"name": "system_lib_string"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "preproc_call_expression"
},
"named": true,
"value": "call_expression"
}
]
}
},
{
"type": "STRING",
"value": "\n"
}
]
},

+ 8
- 0
src/node-types.json Wyświetl plik

@ -2471,6 +2471,14 @@
"multiple": false,
"required": true,
"types": [
{
"type": "call_expression",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "string_literal",
"named": true

+ 31284
- 31797
src/parser.c
Plik diff jest za duży
Wyświetl plik


+ 8
- 1
test/corpus/preprocessor.txt Wyświetl plik

@ -4,12 +4,19 @@ Include directives
#include "some/path.h"
#include <stdint.h>
#include MACRO
#include MACRO(arg1, arg2)
---
(translation_unit
(preproc_include path: (string_literal))
(preproc_include path: (system_lib_string)))
(preproc_include path: (system_lib_string))
(preproc_include path: (identifier))
(preproc_include path:
(call_expression
function: (identifier)
arguments: (argument_list (identifier) (identifier)))))
============================================
Object-like macro definitions

Ładowanie…
Anuluj
Zapisz