Skip to content

Commit bad4c90

Browse files
Update symbol syntax.
1 parent 0d632ca commit bad4c90

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

text/0000-symbol-name-mangling-v2.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -391,66 +391,66 @@ The syntax of mangled names is given in extended Backus-Naur form:
391391
- Terminals are within quotes (as in `"_R"`),
392392
- Optional parts are in brackets (as in `[<decimal>]`),
393393
- Repetition (zero or more times) is signified by curly braces (as in `{ <name-prefix> }`)
394+
- Comments are marked with `//`.
394395

396+
Mangled names conform to the following grammar:
395397

396398
```
397399
// The <decimal-number> specifies the encoding version.
398-
<symbol-name> := "_R" [<decimal-number>] <absolute-path> [<instantiating-crate>]
400+
<symbol-name> = "_R" [<decimal-number>] <absolute-path> [<instantiating-crate>]
399401
400-
<absolute-path> := "N" <path-prefix> [<generic-arguments>] "E"
401-
| <substitution>
402+
<absolute-path> = "N" <path-prefix> [<generic-arguments>] "E"
403+
| <substitution>
402404
403-
<path-prefix> := <path-root>
404-
| <path-prefix> <identifier>
405-
| <substitution>
406-
407-
<path-root> := <identifier>
408-
| "M" <type>
409-
| "X" <type> <absolute-path> [<disambiguator>]
405+
<path-prefix> = <identifier>
406+
| "M" <type>
407+
| "X" <type> <absolute-path> [<disambiguator>]
408+
| <path-prefix> <identifier>
409+
| <substitution>
410410
411411
// The <decimal-number> is the length of the identifier in bytes.
412412
// <bytes> is must not start with a decimal digit.
413413
// If the "u" is present then <bytes> is Punycode-encoded.
414-
<identifier> := <decimal-number> <bytes> ["u"] ["V"|"C"] [<disambiguator>]
415-
416-
<type> := <basic-type>
417-
| <absolute-path> // named type
418-
| "A" [<decimal-number>] <type> // [T; N]
419-
| "T" {<type>} "E" // (T1, T2, T3, ...)
420-
| "R" <type> // &T
421-
| "Q" <type> // &mut T
422-
| "P" <type> // *const T
423-
| "O" <type> // *mut T
424-
| "G" <identifier> "E" // generic parameter name
425-
| <function-type>
426-
| <substitution>
427-
428-
<basic-type> := "a" // i8
429-
| "b" // bool
430-
| "c" // char
431-
| "d" // f64
432-
| "e" // str
433-
| "f" // f32
434-
| "h" // u8
435-
| "i" // isize
436-
| "j" // usize
437-
| "l" // i32
438-
| "m" // u32
439-
| "n" // i128
440-
| "o" // u128
441-
| "s" // i16
442-
| "t" // u16
443-
| "u" // ()
444-
| "v" // ...
445-
| "x" // i64
446-
| "y" // u64
447-
| "z" // !
414+
<identifier> = <decimal-number> <bytes> ["u"] ["V"|"C"] [<disambiguator>]
415+
416+
<type> = <basic-type>
417+
| <absolute-path> // named type
418+
| "A" [<decimal-number>] <type> // [T; N]
419+
| "T" {<type>} "E" // (T1, T2, T3, ...)
420+
| "R" <type> // &T
421+
| "Q" <type> // &mut T
422+
| "P" <type> // *const T
423+
| "O" <type> // *mut T
424+
| "G" <identifier> "E" // generic parameter name
425+
| <function-type>
426+
| <substitution>
427+
428+
<basic-type> = "a" // i8
429+
| "b" // bool
430+
| "c" // char
431+
| "d" // f64
432+
| "e" // str
433+
| "f" // f32
434+
| "h" // u8
435+
| "i" // isize
436+
| "j" // usize
437+
| "l" // i32
438+
| "m" // u32
439+
| "n" // i128
440+
| "o" // u128
441+
| "s" // i16
442+
| "t" // u16
443+
| "u" // ()
444+
| "v" // ...
445+
| "x" // i64
446+
| "y" // u64
447+
| "z" // !
448448
449449
// If the "U" is present then the function is `unsafe`.
450450
// If the "J" is present then it is followed by the return type of the function.
451451
<function-type> := "F" ["U"] [<abi>] {<type>} ["J" <type>] "E"
452452
453-
<abi> := "K" (
453+
<abi> = "K" (
454454
"d" | // Cdecl
455455
"s" | // Stdcall
456456
"f" | // Fastcall
@@ -469,16 +469,16 @@ The syntax of mangled names is given in extended Backus-Naur form:
469469
"j" | // RustInstrinsic
470470
"p" | // PlatformInstrinsic
471471
"u" // Unadjusted
472-
)
472+
)
473473
474-
<disambiguator> := "s" [<hex-digit>] "_"
474+
<disambiguator> = "s" [<hex-digit>] "_"
475475
476-
<generic-arguments> := "I" {<type>} "E"
476+
<generic-arguments> = "I" {<type>} "E"
477477
478-
<substitution> := "S" [<hex-digit>] "_"
478+
<substitution> = "S" [<hex-digit>] "_"
479479
480-
// We use <path-prefix> here, so that we don't have to add a special for
481-
// compression. In practice, only crate-id <path-root> is expected.
480+
// We use <path-prefix> here, so that we don't have to add a special rule for
481+
// compression. In practice, only <identifier> is expected.
482482
<instantiating-crate> := <path-prefix>
483483
```
484484

0 commit comments

Comments
 (0)