forked from p4lang/pna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p4.json
118 lines (88 loc) · 3.13 KB
/
p4.json
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
112
113
114
115
116
117
118
{
"displayName": "P4",
"name": "p4",
"lineComment": "//",
"blockCommentStart": "/*",
"blockCommentEnd": "*/",
"keywords": [ "action", "apply", "control", "default", "else",
"extern", "exit", "false", "if",
"package", "parser", "return", "select", "state", "switch",
"table", "transition", "true", "typedef", "verify"
],
"extraKeywords": [],
"typeKeywords": [
"bool", "bit", "const", "enum", "entries", "error", "header", "header_union", "in", "inout", "int", "match_kind", "out", "tuple", "struct", "varbit", "void"
],
"extraTypeKeywords": [],
"directives": [
"include","if","endif","ifdef","define","ifndef","undef","line"
],
"annotations": [
"atomic", "defaultonly", "name", "priority", "tableonly", "hidden", "globalname"
],
"operators": [
"=", ">", "<", "!", "~", "?", ":",
"==", "<=", ">=", "!=", "&&", "||", "++",
"+", "-", "*", "/", "&", "|", "^", "%", "<<",
">>", "&&&", ".."
],
"extraOperators": [],
"symbols": "[=><!~?:&|+\\-*\\/\\^%]+",
"escapes": "\\\\(?:[abfnrtv\\\\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})",
"tokenizer": {
"root": [
["__\\w+", "identifier.predefined"],
["\\w+::(?=\\w)", "namespace" ],
["(namespace)(\\s*)((?:\\w+::)*\\w+)", ["keyword","white","namespace"] ],
["[a-z_$][\\w]*", { "cases": {
"@typeKeywords": "keyword.type",
"@extraTypeKeywords": "keyword.type.extra",
"@keywords": "keyword",
"@extraKeywords": "keyword.extra",
"@default": "identifier" } }],
["^(\\s*#)(\\w+)(.*)", { "cases": {
"$2@directives": ["namespace","namespace","string"],
"@default": ["meta","meta","string"]
}}],
["^(\\s*@)(\\w+)(.*)", { "cases": {
"$2@annotations": ["namespace","namespace","string"],
"@default": ["meta","meta","string"]
}}],
{ "include": "@whitespace" },
["[{}()\\[\\]]", "@brackets"],
["[<>](?!@symbols)", "@brackets"],
["@symbols", { "cases": {
"@operators": "operator",
"@extraOperators": "operator.extra",
"@default" : "" } } ],
["\\d*\\.\\d+([eE][\\-+]?\\d+)?[fFdD]?", "number.float"],
["0[xX][0-9a-fA-F_]*[0-9a-fA-F][Ll]?", "number.hex"],
["0[0-7_]*[0-7][Ll]?", "number.octal"],
["0[bB][0-1_]*[0-1][Ll]?", "number.binary"],
["\\d+[lL]?", "number"],
["[;,.]", "delimiter"],
["[lL]\"([^\"\\\\]|\\\\.)*$", "string.invalid" ],
["\"", "string", "@string" ],
["'[^\\\\']'", "string"],
["(')(@escapes)(')", ["string","string.escape","string"]],
["'", "string.invalid"]
],
"whitespace": [
["[ \\t\\r\\n]+", "white"],
["\\/\\*", "comment", "@comment" ],
["\\/\\/.*$", "comment"]
],
"comment": [
["[^\\/*]+", "comment" ],
["\\/\\*", "comment.invalid" ],
["\\*/", "comment", "@pop" ],
["[\\/*]", "comment" ]
],
"string": [
["[^\\\\\"]+", "string"],
["@escapes", "string.escape"],
["\\\\.", "string.escape.invalid"],
["\"", "string", "@pop" ]
]
}
}