-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtree-sitter-linkerscript.ebnf
More file actions
147 lines (110 loc) · 3.21 KB
/
tree-sitter-linkerscript.ebnf
File metadata and controls
147 lines (110 loc) · 3.21 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//
// From tree-sitter-linkerscript/src/grammar.json
//
//
// EBNF to generate railroad diagram at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
linkerscript ::=
entry_command? _command*
entry_command ::=
'ENTRY' '(' symbol ')'
_command ::=
assignment
| sections_command
| memory_command
| phdrs_command
sections_command ::=
'SECTIONS' '{' _output_section_command* '}'
_output_section_command ::=
output_section
| overlay_command
| assignment
| assert_command
output_section ::=
( symbol | '/DISCARD/' ) expression? section_type? ':'? _at? '{' ( ( input_section | assignment | keep_command | provide_command ) ';'? )+ '}' region? lma_region? phdr? fillexp?
_at ::=
'AT' '(' expression ')'
region ::=
'>' symbol
lma_region ::=
'AT' '>' symbol
phdr ::=
':' symbol
fillexp ::=
'=' expression
section_type ::=
'(' ( 'NOLOAD' | 'DSECT' | 'COPY' | 'INFO' | 'OVERLAY' ) ')'
input_section ::=
( wildcard_pattern | filename | symbol ) ( '(' ( filename | expression | wildcard_pattern )+ ')' )?
wildcard_pattern ::=
( '[' symbol ']' )? '*'
overlay_command ::=
'OVERLAY' expression? ':' 'NOCROSSREFS'? _at? '{' _output_section_command* '}' region? phdr? fillexp?
assignment ::=
( symbol | '.' ) ( '=' | '+=' | '-=' | '*=' | '/=' | '<<=' | '>>=' | '&=' | '|=' ) expression ';'
assert_command ::=
'ASSERT' '(' expression ( ',' expression )* ')'
keep_command ::=
'KEEP' '(' input_section? ')'
provide_command ::=
( 'PROVIDE' | 'PROVIDE_HIDDEN' ) '(' symbol '=' expression ')' ';'
memory_command ::=
'MEMORY' '{' _memory* '}'
_memory ::=
symbol ( '(' attributes ')' | attributes )? ':' ( 'ORIGIN' | 'org' | 'o' ) '=' expression ',' ( 'LENGTH' | 'len' | 'l' ) '=' expression
attributes ::=
[rwxail!]+
phdrs_command ::=
'PHDRS' '{' _phdr* '}'
_phdr ::=
symbol symbol 'FILEHDR'? 'PHDRS'? _at? ';'
expression ::=
conditional_expression
| unary_expression
| binary_expression
| parenthesized_expression
| call_expression
| symbol
| quoted_symbol
| number
| '.'
conditional_expression ::=
expression '?' expression? ':' expression
unary_expression ::=
( '!' | '~' | '-' ) expression
binary_expression ::=
expression '+' expression
| expression '-' expression
| expression '*' expression
| expression '/' expression
| expression '%' expression
| expression '||' expression
| expression '&&' expression
| expression '|' expression
| expression '&' expression
| expression '==' expression
| expression '!=' expression
| expression '>' expression
| expression '>=' expression
| expression '<=' expression
| expression '<' expression
| expression '<<' expression
| expression '>>' expression
parenthesized_expression ::=
'(' expression ')'
call_expression ::=
expression argument_list
argument_list ::=
'(' ( ( expression | input_section ) ( ',' ( expression | input_section ) )* )? ')'
number ::=
( '0'[xX][a-fA-F0-9]+ | '0'[bB][01]+ | '0'[0-7]+ | '0'|[1-9][0-9]*('h'|'H'|'o'|'O'|'b'|'B'|'d'|'D'|'K'|'M')? )
symbol ::=
[a-zA-Z_.][a-zA-Z0-9_.-]*
quoted_symbol ::=
'"' [^"]* '"'
filename ::=
[^(){};=, #x09#x0A#x0B#x0C#x0D]+
comment ::=
( '//' ('\'+('.'|'#x0D'?'#x0A')|[^\#x0A])* | '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' )