A Symbol is a unique identifier for code entities (classes, methods, variables) similar to a URI. It follows a specific string representation grammar that allows it to be used interchangeably with the Symbol object.
Grammar Structure:
<scheme> <manager> <package-name> <version> <descriptor>+ or local <local-id>
Key Components:
- Scheme: Any UTF-8 string (escape spaces with double space). Must not be empty or start with 'local'.
- Package: Composed of a
manager, package-name, and version. - Descriptor: A sequence of descriptors that form a fully qualified name (e.g.,
Namespace, Type, Method, Parameter). - Local Symbols: Used for entities accessible only within a single
Document.
<symbol> ::= <scheme> ' ' <package> ' ' (<descriptor>)+ | 'local ' <local-id>
<package> ::= <manager> ' ' <package-name> ' ' <version>
<scheme> ::= any UTF-8, escape spaces with double space. Must not be empty nor start with 'local'
<manager> ::= any UTF-8, escape spaces with double space. Use the placeholder '.' to indicate an empty value
<package-name> ::= same as above
<version> ::= same as above
<descriptor> ::= <namespace> | <type> | <term> | <method> | <type-parameter> | <parameter> | <meta> | <macro>
<namespace> ::= <name> '/'
<type> ::= <name> '#'
<term> ::= <name> '.'
<meta> ::= <name> ':'
<macro> ::= <name> '!'
<method> ::= <name> '(' (<method-disambiguator>)? ').'
<type-parameter> ::= '[' <name> ']'
<parameter> ::= '(' <name> ')'
<name> ::= <identifier>
<method-disambiguator> ::= <simple-identifier>
<identifier> ::= <simple-identifier> | <escaped-identifier>
<simple-identifier> ::= (<identifier-character>)+
<identifier-character> ::= '_' | '+' | '-' | '$' | ASCII letter or digit
<escaped-identifier> ::= '`' (<escaped-character>)+ '`'
<escaped-characters> ::= any UTF-8, escape backticks with double backtick.
<local-id> ::= <simple-identifier>