File: awkward_datashape_grammar.g

package info (click to toggle)
python-awkward 2.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 23,088 kB
  • sloc: python: 148,689; cpp: 33,562; sh: 432; makefile: 21; javascript: 8
file content (111 lines) | stat: -rw-r--r-- 2,649 bytes parent folder | download
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
start: type

type: numpytype
    | unknowntype
    | regulartype
    | listtype
    | varlen_string
    | fixedlen_string
    | char
    | byte
    | option1
    | option2
    | tuple
    | tuple_parameters
    | record
    | record_parameters
    | named0
    | named
    | union
    | list_parameters
    | categorical

numpytype: numpytype_name ("[" "parameters" "=" json_object "]")?

numpytype_name: DTYPE
              | DATETIME64
              | TIMEDELTA64

DTYPE.2: "bool"
       | "int8"
       | "uint8"
       | "int16"
       | "uint16"
       | "int32"
       | "uint32"
       | "int64"
       | "uint64"
       | "float32"
       | "float64"
       | "complex64"
       | "complex128"

DATETIME64:  /datetime64(\[(\s*-?[0-9]*)?(Y|M|W|D|h|m|s|ms|us|\u03bc|ns|ps|fs|as)\])?/
TIMEDELTA64: /timedelta64(\[(\s*-?[0-9]*)?(Y|M|W|D|h|m|s|ms|us|\u03bc|ns|ps|fs|as)\])?/

unknowntype: "unknown" ("[" "parameters" "=" json_object "]")?

regulartype: INT "*" type

listtype: "var" "*" type

varlen_string: "string" -> varlen_string
             | "bytes" -> varlen_bytestring

fixedlen_string: ("string" "[" INT "]") -> fixedlen_string
               | ("bytes" "[" INT "]") -> fixedlen_bytestring

char: "char"

byte: "byte"

option1: "?" type

option2: "option" "[" type ("," "parameters" "=" json_object)? "]"

tuple: "(" types? ")"
types: type ("," type)*

tuple_parameters: "tuple" "[" "[" types? "]" ("," "parameters" "=" json_object)? "]"

record: "{" pairs? "}"
pairs:  pair ("," pair)*
pair:   key ":" type
key:    ESCAPED_STRING -> string
      | CNAME          -> identifier

record_parameters: "struct" "[" "{" pairs? "}" ("," "parameters" "=" json_object)? "]"

named0:      CNAME "[" ("parameters" "=" json_object)? "]"
named:       CNAME "[" (named_types | named_pairs) "]"
named_types: type ("," (named_types | "parameters" "=" json_object))?
named_pairs: named_pair ("," (named_pairs | "parameters" "=" json_object))?
named_pair:  named_key ":" type
named_key:   ESCAPED_STRING -> string
           | CNAME          -> identifier

union: "union" "[" named_types? "]"

list_parameters: "[" type "," "parameters" "=" json_object "]"

categorical: "categorical" "[" "type" "=" type "]"

json: ESCAPED_STRING -> string
    | SIGNED_NUMBER  -> number
    | "true"         -> true
    | "false"        -> false
    | "null"         -> null
    | json_array
    | json_object

json_array:  "[" [json ("," json)*] "]"
json_object: "{" [json_pair ("," json_pair)*] "}"
json_pair:   ESCAPED_STRING ":" json

%import common.INT
%import common.CNAME
%import common.ESCAPED_STRING
%import common.SIGNED_NUMBER
%import common.WS

%ignore WS