Просмотр исходного кода

Remove error rules

pull/2/head
Max Brunsfeld 10 лет назад
Родитель
Сommit
e270a9c486
2 измененных файлов: 87 добавлений и 100 удалений
  1. +14
    -10
      grammar.js
  2. +73
    -90
      src/grammar.json

+ 14
- 10
grammar.js Просмотреть файл

@ -90,11 +90,11 @@ module.exports = grammar({
preproc_ifdef: $ => seq( preproc_ifdef: $ => seq(
choice('#ifdef', '#ifndef'), choice('#ifdef', '#ifndef'),
$.identifier, $.identifier,
err(repeat(choice(
repeat(choice(
$._preproc_statement, $._preproc_statement,
$.function_definition, $.function_definition,
$.declaration $.declaration
))),
)),
optional($.preproc_else), optional($.preproc_else),
'#endif' '#endif'
), ),
@ -120,12 +120,12 @@ module.exports = grammar({
), ),
declaration: $ => seq( 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( 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, $.number_literal,
$.string_literal, $.string_literal,
$.char_literal, $.char_literal,
seq('(', err($._expression), ')')
seq('(', $._expression, ')')
), ),
conditional_expression: $ => prec.right(PREC.CONDITIONAL, seq( conditional_expression: $ => prec.right(PREC.CONDITIONAL, seq(

+ 73
- 90
src/grammar.json Просмотреть файл

@ -255,26 +255,23 @@
"name": "identifier" "name": "identifier"
}, },
{ {
"type": "ERROR",
"type": "REPEAT",
"content": { "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", "type": "SEQ",
"members": [ "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": [ "members": [
{ {
"type": "SYMBOL",
"name": "_declaration_specifiers"
"type": "STRING",
"value": ","
}, },
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_type_specifier"
},
{
"type": "SEQ",
"members": [
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
@ -396,36 +410,11 @@
"name": "init_declarator" "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", "type": "STRING",
@ -835,26 +824,23 @@
"value": "{" "value": "{"
}, },
{ {
"type": "ERROR",
"type": "REPEAT",
"content": { "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": "(" "value": "("
}, },
{ {
"type": "ERROR",
"content": {
"type": "SYMBOL",
"name": "_expression"
}
"type": "SYMBOL",
"name": "_expression"
}, },
{ {
"type": "STRING", "type": "STRING",

Загрузка…
Отмена
Сохранить