-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrammarcppcommon.ebnf
More file actions
129 lines (125 loc) · 2.83 KB
/
grammarcppcommon.ebnf
File metadata and controls
129 lines (125 loc) · 2.83 KB
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
123
124
125
126
127
128
129
// Section lex.charset
fragment HexQuad
= HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit
;
fragment UniversalCharacterName
= "\\u" HexQuad
| "\\U" HexQuad HexQuad
;
// Section lex.name
token Identifier @lowPrio
= IdentifierNondigit
| Identifier IdentifierNondigit
| Identifier Digit
;
fragment IdentifierNondigit
= Nondigit
| UniversalCharacterName
| [$]
;
fragment Nondigit
= [a-zA-Z_]
;
fragment Digit
= [0-9]
;
// Section lex.icon
fragment OctalDigit
= [0-7]
;
fragment HexadecimalDigit
= [0-9a-fA-F]
;
// Section lex.ccon
token CharacterLiteral
= "'" CCharSequence "'"
| "u" "'" CCharSequence "'"
| "U" "'" CCharSequence "'"
| "L" "'" CCharSequence "'"
;
fragment CCharSequence
= CChar
| CCharSequence CChar
;
fragment CChar
/* any member of the source character set except
* the single-quote ', backslash \, or new-line character */
= [^'\\\n]
| EscapeSequence
| UniversalCharacterName
;
fragment EscapeSequence
= SimpleEscapeSequence
| OctalEscapeSequence
| HexadecimalEscapeSequence
| "\\" "\r"? "\n"
;
fragment SimpleEscapeSequence
= "\\'"
| "\\\""
| "\\?"
| "\\\\"
| "\\a"
| "\\b"
| "\\f"
| "\\n"
| "\\r"
| "\\t"
| "\\v"
;
fragment OctalEscapeSequence
= "\\" OctalDigit
| "\\" OctalDigit OctalDigit
| "\\" OctalDigit OctalDigit OctalDigit
;
fragment HexadecimalEscapeSequence
= "\\x" HexadecimalDigit
| HexadecimalEscapeSequence HexadecimalDigit
;
// Section lex.string
token StringLiteral @minimalMatch
= EncodingPrefix? "\"" SCharSequence? "\""
| EncodingPrefix? "R" RawString
;
fragment EncodingPrefix
= "u8"
| "u"
| "U"
| "L"
;
fragment SCharSequence
= SChar
| SCharSequence SChar
;
fragment SChar
/* any member of the source character set except
* the double-quote ", backslash \, or new-line character */
= [^\"\\\n]
| EscapeSequence
| UniversalCharacterName
;
fragment RawString
= "\"(" RCharSequence? ")\""
| "\"" @store DCharSequence "(" RCharSequence? ")" @compareTrue DCharSequence "\""
;
fragment RCharSequence
= RChar
| RCharSequence RChar
;
fragment RChar
/* any member of the source character set, except
* a right parenthesis ) followed by the initial DCharSequence
* (which may be empty) followed by a double quote ". */
= [^]
;
fragment DCharSequence
= DChar
| DCharSequence DChar
;
fragment DChar
/* any member of the basic source character set except:
* space, the left parenthesis (, the right parenthesis ), the backslash \,
* and the control characters representing horizontal tab,
* vertical tab, form feed, and newline. */
= [^ ()\\\t\f\r\n]
;