Add support for gnatprep directives
They can be folded
This commit is contained in:
parent
39697ddca8
commit
7fe1b1edb4
48
grammar.js
48
grammar.js
|
|
@ -120,6 +120,8 @@ module.exports = grammar({
|
||||||
|
|
||||||
identifier: $ =>
|
identifier: $ =>
|
||||||
/[a-zA-Z\u{80}-\u{10FFFF}][0-9a-zA-Z_\u{80}-\u{10FFFF}]*/u,
|
/[a-zA-Z\u{80}-\u{10FFFF}][0-9a-zA-Z_\u{80}-\u{10FFFF}]*/u,
|
||||||
|
gnatprep_identifier: $ =>
|
||||||
|
/\$[a-zA-Z\u{80}-\u{10FFFF}][0-9a-zA-Z_\u{80}-\u{10FFFF}]*/u,
|
||||||
comment: $ => token(seq('--', /.*/)),
|
comment: $ => token(seq('--', /.*/)),
|
||||||
string_literal: $ => token(/"(""|[^"])*"/),
|
string_literal: $ => token(/"(""|[^"])*"/),
|
||||||
character_literal: $ => token(/'.'/),
|
character_literal: $ => token(/'.'/),
|
||||||
|
|
@ -129,6 +131,11 @@ module.exports = grammar({
|
||||||
/[0-9]+#[0-9a-fA-F._-]+#([eE][+-]?[0-9_]+)?/,
|
/[0-9]+#[0-9a-fA-F._-]+#([eE][+-]?[0-9_]+)?/,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
git_conflict_mark: $ => choice(
|
||||||
|
token(seq(reservedWord('<<<<<<<'), /.*/)),
|
||||||
|
token(seq(reservedWord('>>>>>>>'), /.*/)),
|
||||||
|
token(seq(reservedWord('======='), /.*/)),
|
||||||
|
),
|
||||||
relational_operator: $ => choice('=', '/=', '<', '<=', '>', '>='),
|
relational_operator: $ => choice('=', '/=', '<', '<=', '>', '>='),
|
||||||
binary_adding_operator: $ => choice('+', '-', '&'),
|
binary_adding_operator: $ => choice('+', '-', '&'),
|
||||||
unary_adding_operator: $ => choice('+', '-'),
|
unary_adding_operator: $ => choice('+', '-'),
|
||||||
|
|
@ -137,6 +144,7 @@ module.exports = grammar({
|
||||||
|
|
||||||
_name_not_function_call: $ => choice( // RM 4.1
|
_name_not_function_call: $ => choice( // RM 4.1
|
||||||
$.identifier,
|
$.identifier,
|
||||||
|
$.gnatprep_identifier,
|
||||||
$.selected_component,
|
$.selected_component,
|
||||||
$._attribute_reference,
|
$._attribute_reference,
|
||||||
$.qualified_expression,
|
$.qualified_expression,
|
||||||
|
|
@ -1329,6 +1337,7 @@ module.exports = grammar({
|
||||||
_declarative_item_pragma: $ => choice(
|
_declarative_item_pragma: $ => choice(
|
||||||
$._declarative_item,
|
$._declarative_item,
|
||||||
$.pragma_g,
|
$.pragma_g,
|
||||||
|
$.gnatprep_declarative_if_statement,
|
||||||
),
|
),
|
||||||
|
|
||||||
// Although it doesn't add any new character, we keep this rule as an
|
// Although it doesn't add any new character, we keep this rule as an
|
||||||
|
|
@ -2020,6 +2029,7 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
_compound_statement: $ => choice(
|
_compound_statement: $ => choice(
|
||||||
$.if_statement,
|
$.if_statement,
|
||||||
|
$.gnatprep_if_statement,
|
||||||
$.case_statement,
|
$.case_statement,
|
||||||
$.loop_statement,
|
$.loop_statement,
|
||||||
$.block_statement,
|
$.block_statement,
|
||||||
|
|
@ -2194,6 +2204,44 @@ module.exports = grammar({
|
||||||
reservedWord('then'),
|
reservedWord('then'),
|
||||||
field('statements', $._sequence_of_statements),
|
field('statements', $._sequence_of_statements),
|
||||||
),
|
),
|
||||||
|
gnatprep_declarative_if_statement: $ => seq(
|
||||||
|
reservedWord('#if'),
|
||||||
|
field('condition', $.expression),
|
||||||
|
reservedWord('then'),
|
||||||
|
$.non_empty_declarative_part,
|
||||||
|
repeat(seq(
|
||||||
|
reservedWord('#elsif'),
|
||||||
|
field('condition', $.expression),
|
||||||
|
reservedWord('then'),
|
||||||
|
$.non_empty_declarative_part,
|
||||||
|
)),
|
||||||
|
optional(seq(
|
||||||
|
reservedWord('#else'),
|
||||||
|
$.non_empty_declarative_part,
|
||||||
|
)),
|
||||||
|
reservedWord('#end'),
|
||||||
|
reservedWord('if'),
|
||||||
|
';',
|
||||||
|
),
|
||||||
|
gnatprep_if_statement: $ => seq(
|
||||||
|
reservedWord('#if'),
|
||||||
|
field('condition', $.expression),
|
||||||
|
reservedWord('then'),
|
||||||
|
field('statements', $._sequence_of_statements),
|
||||||
|
repeat(seq(
|
||||||
|
reservedWord('#elsif'),
|
||||||
|
field('condition', $.expression),
|
||||||
|
reservedWord('then'),
|
||||||
|
field('statements', $._sequence_of_statements),
|
||||||
|
)),
|
||||||
|
optional(seq(
|
||||||
|
reservedWord('#else'),
|
||||||
|
field('else_statements', $._sequence_of_statements),
|
||||||
|
)),
|
||||||
|
reservedWord('#end'),
|
||||||
|
reservedWord('if'),
|
||||||
|
';',
|
||||||
|
),
|
||||||
exit_statement: $ => seq( // ARM 5.7
|
exit_statement: $ => seq( // ARM 5.7
|
||||||
reservedWord('exit'),
|
reservedWord('exit'),
|
||||||
field('loop_name', optional($._name)),
|
field('loop_name', optional($._name)),
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,6 @@
|
||||||
(block_statement)
|
(block_statement)
|
||||||
(if_statement)
|
(if_statement)
|
||||||
(loop_statement)
|
(loop_statement)
|
||||||
|
(gnatprep_declarative_if_statement)
|
||||||
|
(gnatprep_if_statement)
|
||||||
] @fold
|
] @fold
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,10 @@
|
||||||
|
|
||||||
(raise_statement "with" @exception)
|
(raise_statement "with" @exception)
|
||||||
|
|
||||||
|
(gnatprep_declarative_if_statement) @preproc
|
||||||
|
(gnatprep_if_statement) @preproc
|
||||||
|
(gnatprep_identifier) @preproc
|
||||||
|
|
||||||
(subprogram_declaration "is" @keyword.function "abstract" @keyword.function)
|
(subprogram_declaration "is" @keyword.function "abstract" @keyword.function)
|
||||||
(aspect_specification "with" @keyword.function)
|
(aspect_specification "with" @keyword.function)
|
||||||
|
|
||||||
|
|
|
||||||
471
src/grammar.json
471
src/grammar.json
|
|
@ -13,6 +13,10 @@
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[a-zA-Z\\u{80}-\\u{10FFFF}][0-9a-zA-Z_\\u{80}-\\u{10FFFF}]*"
|
"value": "[a-zA-Z\\u{80}-\\u{10FFFF}][0-9a-zA-Z_\\u{80}-\\u{10FFFF}]*"
|
||||||
},
|
},
|
||||||
|
"gnatprep_identifier": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "\\$[a-zA-Z\\u{80}-\\u{10FFFF}][0-9a-zA-Z_\\u{80}-\\u{10FFFF}]*"
|
||||||
|
},
|
||||||
"comment": {
|
"comment": {
|
||||||
"type": "TOKEN",
|
"type": "TOKEN",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
@ -59,6 +63,95 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"git_conflict_mark": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[<<][<<][<<][<<][<<][<<][<<]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "<<<<<<<"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": ".*"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[>>][>>][>>][>>][>>][>>][>>]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": ">>>>>>>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": ".*"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[==][==][==][==][==][==][==]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "======="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": ".*"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"relational_operator": {
|
"relational_operator": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
@ -150,6 +243,10 @@
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "identifier"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "gnatprep_identifier"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "selected_component"
|
"name": "selected_component"
|
||||||
|
|
@ -7785,6 +7882,10 @@
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "pragma_g"
|
"name": "pragma_g"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "gnatprep_declarative_if_statement"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -8306,13 +8407,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_exception_handler_list": {
|
|
||||||
"type": "REPEAT1",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "exception_handler"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"formal_part": {
|
"formal_part": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
@ -10076,8 +10170,11 @@
|
||||||
"value": "exception"
|
"value": "exception"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "REPEAT1",
|
||||||
"name": "_exception_handler_list"
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "exception_handler"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -12326,6 +12423,10 @@
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "if_statement"
|
"name": "if_statement"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "gnatprep_if_statement"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "case_statement"
|
"name": "case_statement"
|
||||||
|
|
@ -13666,6 +13767,358 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"gnatprep_declarative_if_statement": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[##][iI][fF]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "#if"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "condition",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expression"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[tT][hH][eE][nN]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "then"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "non_empty_declarative_part"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[##][eE][lL][sS][iI][fF]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "#elsif"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "condition",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expression"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[tT][hH][eE][nN]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "then"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "non_empty_declarative_part"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[##][eE][lL][sS][eE]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "#else"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "non_empty_declarative_part"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[##][eE][nN][dD]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "#end"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[iI][fF]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "if"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ";"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gnatprep_if_statement": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[##][iI][fF]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "#if"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "condition",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expression"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[tT][hH][eE][nN]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "then"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "statements",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_sequence_of_statements"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[##][eE][lL][sS][iI][fF]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "#elsif"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "condition",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expression"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[tT][hH][eE][nN]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "then"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "statements",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_sequence_of_statements"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[##][eE][lL][sS][eE]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "#else"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "else_statements",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_sequence_of_statements"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[##][eE][nN][dD]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "#end"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 2,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[iI][fF]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "if"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ";"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"exit_statement": {
|
"exit_statement": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
92757
src/parser.c
92757
src/parser.c
File diff suppressed because it is too large
Load Diff
55
test/corpus/preprocessor.txt
Normal file
55
test/corpus/preprocessor.txt
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
================================================================================
|
||||||
|
Preprocess-if (GNAT)
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
procedure P is
|
||||||
|
#if not CHECKING_MODE then
|
||||||
|
pragma Suppress (Access_Checks);
|
||||||
|
#end if;
|
||||||
|
begin
|
||||||
|
null;
|
||||||
|
end;
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(subprogram_body
|
||||||
|
(procedure_specification
|
||||||
|
(identifier))
|
||||||
|
(non_empty_declarative_part
|
||||||
|
(gnatprep_declarative_if_statement
|
||||||
|
(expression
|
||||||
|
(term
|
||||||
|
(factor_not
|
||||||
|
(identifier))))
|
||||||
|
(non_empty_declarative_part
|
||||||
|
(pragma_g
|
||||||
|
(identifier)
|
||||||
|
(pragma_argument_association
|
||||||
|
(expression
|
||||||
|
(term
|
||||||
|
(identifier))))))))
|
||||||
|
(handled_sequence_of_statements
|
||||||
|
(null_statement)))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Preprocess substitution (GNAT)
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
package P is
|
||||||
|
Flavour : constant F := $FLAVOR;
|
||||||
|
end;
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(package_specification
|
||||||
|
(identifier)
|
||||||
|
(object_declaration
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(term
|
||||||
|
(gnatprep_identifier)))))))
|
||||||
|
|
@ -543,9 +543,9 @@ end;
|
||||||
(term
|
(term
|
||||||
(target_name)))))))))))))
|
(target_name)))))))))))))
|
||||||
|
|
||||||
=======
|
================================================================================
|
||||||
if-expressions
|
if-expressions
|
||||||
=======
|
================================================================================
|
||||||
|
|
||||||
procedure P is
|
procedure P is
|
||||||
begin
|
begin
|
||||||
|
|
@ -553,7 +553,7 @@ begin
|
||||||
S := new String'(if N /= "" then N else "12");
|
S := new String'(if N /= "" then N else "12");
|
||||||
end;
|
end;
|
||||||
|
|
||||||
-----
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(compilation
|
(compilation
|
||||||
(compilation_unit
|
(compilation_unit
|
||||||
|
|
@ -606,9 +606,9 @@ end;
|
||||||
(term
|
(term
|
||||||
(string_literal)))))))))))))
|
(string_literal)))))))))))))
|
||||||
|
|
||||||
=======
|
================================================================================
|
||||||
Re-raise
|
Re-raise
|
||||||
=======
|
================================================================================
|
||||||
|
|
||||||
procedure P is
|
procedure P is
|
||||||
begin
|
begin
|
||||||
|
|
@ -620,7 +620,7 @@ exception
|
||||||
raise;
|
raise;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(compilation
|
(compilation
|
||||||
(compilation_unit
|
(compilation_unit
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user