-
Notifications
You must be signed in to change notification settings - Fork 35
/
bnf_rb.txt
90 lines (70 loc) · 3.83 KB
/
bnf_rb.txt
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
//**************************************************************************
//* COPYRIGHT:
//* Copyright (c) 2001, International Business Machines Corporation and
//* others. All Rights Reserved.
//**************************************************************************
// Created by: Vladimir Weinstein, 07/27/2001
// This is the resource bundle formal definition.
// NOTE: this is not complete definition in the strictest sense,
// you have to read the comments to know everything.
// Complete definition would be much harder to read.
resourceBundle ::= bundleName table
// These are the currently supported resources
resource ::= string | array | table | binary | integer | intvector | import | include
//** aggregate resources
table ::= (':table')? '{' (key resource)* '}'
// Has to have type name if containing zero elements except when starting
// a resource bundle
array ::= (':array')? '{' resource? | (resource (',' resource)+ ','?) '}'
// Has to have type name if containing zero or one element
//** Leaf resources
string ::= (':string')?'{'('"'unicodeChar*'"') | unicodeChar+ '}'
// String should be quoted if contains interesting chars or empty
binary ::= ( ':binary' | ':bin' ) '{' ('"' (hexDigit hexDigit)* '"') | (hexDigit hexDigit)+'}'
// You should use quotes if you want to have an empty binary
integer ::= (':integer' | ':int') '{' number '}'
// single integers are 28-bit values, see below
intvector ::= ':intvector' '{' number? | (number ( ',' number)+ ','?) '}'
// integer vectors contain 32-bit integer values, see below
// imports a file from the given path as binary
import ::= ':import' '{' path '}'
// Alias stores the path to a different resource in the current bundle
// and at runtime, the API resolves the alias and retuns the resource
alias ::= ':alias' '{' path'}'
// Includes the contents of a file given by the path as a string in the resource bundle.
// Recognizes Unicode encodings if the file is tagged with a BOM.
// Does not recognize/convert non-Unicode encodings.
// Treats all non-Unicode encoded and non-BOM tagged Unicode-encoded files as ASCII and assumes
// \uXXXX and \UXXXXXXXX form for denoting codepoints
include ::= ':include''{' path '}'
// ** Other necessary definitions
key ::= invariantChars | '"' invariantChars '"'
// key should also be quoted if containing interesting chars
bundleName ::= invariantChars
invariantChars ::= invariantChar+
invariantChar ::= [A-Z] | [a-z] | [0-9] | SPACE | " | % | & | ' | ( | ) | *
| + | , | - | . | / | : | ; | < | = | > | ? | _
hexDigit ::= [0-9]|[A-F]|[a-f]
number ::= sign? digit+
sign ::= -
digit ::= [0-9]
// Strings:
// unicodeChar can be either written as a combination of invariant chars and \u & \U literals
// or as UTF-8 or UTF-16 encoded text (which is autodetected if correct BOM is present)
// or using any ICU supported codepage (which requires ICU to be fully built before using)
// Integer values:
// Starting with ICU 2.0, genrb allows integers to be written as decimal
// or hexadecimal (prefix 0x) values.
// The resource bundle format allows to write such values using the full
// negative and positive ranges of both signed and unsigned integers.
// It is up to the runtime application code to determine which resource
// is to be interpreted as signed or unsigned and to use the appropriate API
// (or a cast) to get the value with the desired signedness.
// Single integers (:int or :integer) are 28-bit values.
// Their range is
// Interpreted as signed: -134217728..134217727 (-128M..128M-1, -0x8000000..0x7ffffff)
// Interpreted as unsigned: 0..268435455 (0..256M-1, 0..0xfffffff)
// In integer vectors (:intvector) each vector item is a 32-bit value.
// Their range is
// Interpreted as signed: -2147483648..2147483647 (-2G..2G-1, -0x80000000..0x7fffffff)
// Interpreted as unsigned: 0..4294967295 (0..4G-1, 0..0xffffffff)