Bladeren bron

Don't try to parse #if conditions as C expressions

Doing this required treating the newline that follows these conditions as significant
in order to avoid conflicts, but this caused problems for error recovery.
pull/6/head
Max Brunsfeld 9 jaren geleden
bovenliggende
commit
d9c324ffce
4 gewijzigde bestanden met toevoegingen van 34410 en 37690 verwijderingen
  1. +2
    -4
      corpus/preprocessor.txt
  2. +1
    -2
      grammar.js
  3. +1
    -5
      src/grammar.json
  4. +34406
    -37679
      src/parser.c

+ 2
- 4
corpus/preprocessor.txt Bestand weergeven

@ -107,9 +107,7 @@ General if blocks
(translation_unit
(preproc_if
(logical_expression
(call_expression (identifier) (argument_list (identifier)))
(call_expression (identifier) (argument_list (identifier))))
(preproc_arg)
(preproc_def (identifier) (preproc_arg))))
============================================
@ -131,7 +129,7 @@ int main() {
(identifier)
(function_declarator (identifier))
(compound_statement
(preproc_if (identifier)
(preproc_if (preproc_arg)
(return_statement (number_literal))
(preproc_else
(return_statement (number_literal)))))))

+ 1
- 2
grammar.js Bestand weergeven

@ -129,8 +129,7 @@ module.exports = grammar({
preproc_if: $ => seq(
'#if',
$._expression,
'\n',
$.preproc_arg,
repeat($._top_level_item),
optional($.preproc_else),
'#endif'

+ 1
- 5
src/grammar.json Bestand weergeven

@ -268,11 +268,7 @@
},
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "STRING",
"value": "\n"
"name": "preproc_arg"
},
{
"type": "REPEAT",

+ 34406
- 37679
src/parser.c
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


Laden…
Annuleren
Opslaan