Reputation: 11687
I'm reading Scala Language Reference, and I have troubles with such syntax:
UnicodeEscape ::= \{\\}u{u} hexDigit hexDigit hexDigit hexDigit
hexDigit ::= ‘0’ | ... | ‘9’ | ‘A’ | ... | ‘F’ | ‘a’ | ... | ‘f’
(it is on first page in chapter one). How should I understand it?
Upvotes: 0
Views: 277
Reputation: 10549
This (some kind of) EBNF.
It means that a Unicode token is essentially '\u' followed by four hex digits which are defined in the usual way.
Upvotes: 4
Reputation: 297175
This is EBNF, which is the standard way to present grammars of computer languages.
Upvotes: 4
Reputation: 2609
The syntax is being presented in BNF format. Check out this Wikipedia article for an introduction Backus–Naur Form
Upvotes: 3
Reputation: 54574
hexDigit is a character from the range '0'..'9', 'a'..'f' or 'A'..'F'
UnicodeEscape is something like \uXXXX
where X is a hexDigit. If I read it right, you can have additional u's, but I wouldn't recommend to use this (and never saw anyone using it).
BTW, the rules for this are exactly like for Unicode in Java Strings.
Upvotes: 2