-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathExampleAnnotationGrammar.g4
122 lines (96 loc) · 2.9 KB
/
ExampleAnnotationGrammar.g4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// grammar understood by the ExampleExtractor tool when processing HTML comments containing example annotations.
grammar ExampleAnnotationGrammar;
example_annotation
: '<!-- Example:' '{' annotation_directive (',' annotation_directive)* '}' '-->'
;
annotation_directive
: template
| name
| replace_ellipsis
| custom_ellipsis_replacements
| expected_errors
| expected_warnings
| ignored_warnings
| expected_output
| infer_output
| expected_exception
| additional_files
| extern_alias_support
| execution_arguments
;
JSON_string_value
: '"' ~["\u000D\u000A]+ '"'
;
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines, \r (Windows)
template
: 'template' ':' template_name
;
template_name
: '"code-in-class-lib"' // actually, a JSON_string_value with this content
| '"code-in-class-lib-without-using"' // actually, a JSON_string_value with this content
| '"code-in-main"' // actually, a JSON_string_value with this content
| '"code-in-main-without-using"' // actually, a JSON_string_value with this content
| '"code-in-partial-class"' // actually, a JSON_string_value with this content
| '"extern-lib"' // actually, a JSON_string_value with this content
| '"standalone-console"' // actually, a JSON_string_value with this content
| '"standalone-lib"' // actually, a JSON_string_value with this content
| '"standalone-lib-without-using"' // actually, a JSON_string_value with this content
;
name
: 'name' ':' test_filename
;
test_filename
: JSON_string_value
;
replace_ellipsis
: 'replaceEllipsis' ':' ('true' | 'false')
;
custom_ellipsis_replacements
: 'customEllipsisReplacements' ':' '[' replacement (',' replacement)* ']'
;
replacement
: 'null'
| output_string
;
expected_errors
: 'expectedErrors' ':' '[' cs_number (',' cs_number)* ']'
;
cs_number
: JSON_string_value // of the form "CSnnnn"
;
expected_warnings
: 'expectedWarnings' ':' '[' cs_number (',' cs_number)* ']'
;
ignored_warnings
: 'ignoredWarnings' ':' '[' cs_number (',' cs_number)* ']'
;
expected_output
: 'expectedOutput' ':' '[' output_string (',' output_string)* ']'
;
infer_output
: 'inferOutput' ':' ('true' | 'false')
;
expected_exception
: 'expectedException' ':' exception_name
;
exception_name
: JSON_string_value // an unqualified type name
;
output_string
: JSON_string_value
;
additional_files
: 'additionalFiles' ':' '[' filename (',' filename)* ']'
;
extern_alias_support
: 'project' ':' filename
;
execution_arguments
: 'executionArgs' ':' '[' cmdlinearg (',' cmdlinearg)* ']'
;
cmdlinearg
: JSON_string_value
;
filename
: JSON_string_value
;