-
Notifications
You must be signed in to change notification settings - Fork 3
/
grammar.ne
44 lines (35 loc) · 1.06 KB
/
grammar.ne
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
@{%
const lexer = require("./lexer");
const {
key,
publicKey,
extendedPublicKey,
privateKey,
value,
number,
wildcard,
} = require("./postprocessors");
%}
@lexer lexer
descriptor -> script ("#" %checksum):? {% function(data) { return data[0]; } %}
script -> functionName "(" scriptArg scriptAdditionalArg:* ")" {% function(data) { return [data[0], data[2][0], ...data[3].map(function(arg) {return arg[1][0];})]; } %}
scriptAdditionalArg -> "," scriptArg
scriptArg -> script
| key
| number
| %address
| hex
key -> keyPrefix:? keyBody {% key %}
keyPrefix -> "[" fingerprint derivationPath "]"
keyBody -> %privateKey
| publicKey
| extendedPublicKey
extendedPublicKey -> %extendedPublicKey (derivationPath (wildcard):?):? {% extendedPublicKey %}
publicKey -> %publicKey {% publicKey %}
privateKey -> %privateKey {% privateKey %}
functionName -> %functionName {% value %}
fingerprint -> %fingerprint {% value %}
number -> %number {% number %}
derivationPath -> %derivationPath {% value %}
wildcard -> %wildcard {% wildcard %}
hex -> %hex {% value %}