-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathuuid-grammar.rl
More file actions
85 lines (67 loc) · 1.75 KB
/
uuid-grammar.rl
File metadata and controls
85 lines (67 loc) · 1.75 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
%%{
machine UUID;
action start_uuid {
}
action int60_prefix {
dgt = int(ABC[fc])+4;
atoms[atm][hlf] &= INT60_FLAGS | PREFIX_MASKS[dgt];
}
action int60_dgt {
atoms[atm][hlf] |= ((uint64)(ABC[fc])) << DIGIT_OFFSETS[dgt];
dgt++;
if (dgt>10) {
fbreak;
}
}
action start_full_int {
atoms[atm][hlf] &= INT60_FLAGS;
}
action start_value {
}
action start_origin {
dgt = 0;
hlf = 1;
}
action end_value {
}
action end_origin {
}
action variety {
atoms[atm][hlf] <<= 6;
dgt--;
}
action uuid_sep {
hlf = 1;
atoms[atm][1] &= INT60_FULL;
atoms[atm][1] |= ((uint64)(ABC[fc]))<<60;
}
action end_name {
atoms[atm][1] = UUID_NAME_FLAG;
}
# Base64 value
DGT = [0-9a-zA-Z~_] @int60_dgt;
BASE = DGT+;
# prefix compression
PREFIX = [([\{\}\])] @int60_prefix;
# UUID type: name, hash, event or derived event
SIGN = [\$\%\+\-] @uuid_sep;
# prefix-compressed int (half of UUID)
PBASE = PREFIX BASE?;
# full int
FBASE = (DGT ([\/] @variety)? DGT*) >start_full_int;
# int, either compressed or not
INT = PBASE | FBASE;
# first half of an UUID
VALUE = INT >start_value %end_value ;
# second half of an UUID
ORIGIN = INT >start_origin %end_origin ;
# prefix-compressed 2nd half
PORIGIN = PBASE >start_origin %end_origin ;
# global name UUID, e.g. "lww" (aka transcendent constant)
NAME = FBASE >start_value %end_value %end_name;
# RON 128 bit UUID
UUID = ( NAME | VALUE ( SIGN ORIGIN? | PORIGIN? ) | SIGN ORIGIN? )
>start_uuid
;
# main := UUID;
}%%