Ver código fonte

Remove error rules

pull/2/head
Max Brunsfeld 10 anos atrás
pai
commit
e270a9c486
2 arquivos alterados com 87 adições e 100 exclusões
  1. +14
    -10
      grammar.js
  2. +73
    -90
      src/grammar.json

+ 14
- 10
grammar.js Ver arquivo

@ -90,11 +90,11 @@ module.exports = grammar({
preproc_ifdef: $ => seq(
choice('#ifdef', '#ifndef'),
$.identifier,
err(repeat(choice(
repeat(choice(
$._preproc_statement,
$.function_definition,
$.declaration
))),
)),
optional($.preproc_else),
'#endif'
),
@ -120,12 +120,12 @@ module.exports = grammar({
),
declaration: $ => seq(
err(seq(
optional($._declaration_specifiers),
$._type_specifier,
commaSep1(choice(
$._declarator,
$.init_declarator)))),
optional($._declaration_specifiers),
$._type_specifier,
commaSep1(choice(
$._declarator,
$.init_declarator
)),
';'
),
@ -201,7 +201,11 @@ module.exports = grammar({
compound_statement: $ => seq(
'{',
err(repeat(choice($.declaration, $._empty_declaration, $._statement))),
repeat(choice(
$.declaration,
$._empty_declaration,
$._statement
)),
'}'
),
@ -427,7 +431,7 @@ module.exports = grammar({
$.number_literal,
$.string_literal,
$.char_literal,
seq('(', err($._expression), ')')
seq('(', $._expression, ')')
),
conditional_expression: $ => prec.right(PREC.CONDITIONAL, seq(

+ 73
- 90
src/grammar.json Ver arquivo

@ -255,26 +255,23 @@
"name": "identifier"
},
{
"type": "ERROR",
"type": "REPEAT",
"content": {
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_preproc_statement"
},
{
"type": "SYMBOL",
"name": "function_definition"
},
{
"type": "SYMBOL",
"name": "declaration"
}
]
}
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_preproc_statement"
},
{
"type": "SYMBOL",
"name": "function_definition"
},
{
"type": "SYMBOL",
"name": "declaration"
}
]
}
},
{
@ -361,29 +358,46 @@
"type": "SEQ",
"members": [
{
"type": "ERROR",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_declaration_specifiers"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_type_specifier"
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_declarator"
},
{
"type": "SYMBOL",
"name": "init_declarator"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_declaration_specifiers"
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_type_specifier"
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
@ -396,36 +410,11 @@
"name": "init_declarator"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_declarator"
},
{
"type": "SYMBOL",
"name": "init_declarator"
}
]
}
]
}
}
]
}
]
}
}
]
},
{
"type": "STRING",
@ -835,26 +824,23 @@
"value": "{"
},
{
"type": "ERROR",
"type": "REPEAT",
"content": {
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "declaration"
},
{
"type": "SYMBOL",
"name": "_empty_declaration"
},
{
"type": "SYMBOL",
"name": "_statement"
}
]
}
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "declaration"
},
{
"type": "SYMBOL",
"name": "_empty_declaration"
},
{
"type": "SYMBOL",
"name": "_statement"
}
]
}
},
{
@ -1851,11 +1837,8 @@
"value": "("
},
{
"type": "ERROR",
"content": {
"type": "SYMBOL",
"name": "_expression"
}
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "STRING",

Carregando…
Cancelar
Salvar