~sircmpwn/ipcgen

ipcgen/doc/grammar.txt -rw-r--r-- 2.9 KiB
4bb1b23dDrew DeVault lex: update bufio usage a month ago
                                                                                
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# nonterminal
#	alternative
#	...
#
# * indicates zero or more items
# <n>* indicates N or more items
# [optional] items are bracketed
# /.../ indicates a regex rule
#
# Whitespace is ignored.
#
# Invariants:
#
# - A set of "in" and "out" parameters is only supported with the "call" IPC
#   method (call foo{a, b, c; d, e, f}(...)).
# - Result types using "options" may include up to one "type" (or void), any
#   number of unit types, and any number of error types (or "error" for any
#   error).
# - All names must be unique
#
# ABI:
#
# Each interface is assigned a unique ID by taking the FNV-32 of its name
#
# A message label is iface << 16 | serial, where serial is assigned from 0 for
# each method in order of appearance.
#
# Each IPC message has two result registers: the label of the message tag, and
# the IPC register.
#
# The label selects the result type from among the options and has the
# following 48-bit format:
#
# 0000000000000000HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
#
# If the result is a primitive or enum type, all bits are set to zero. For unit
# and error results, H is set to the FNV-32 hash of the fully qualified
# identifier of the unit or error in question. All of the 0 bits are reserved.
#
# A side-effect of this design is that errors and unit types have a 32-bit
# identifier equal to their Hare type ID.
#
# The actual value of a nominal reply is stored in register two as the
# appropriate type (e.g. uint). Errors which include a value store this value in
# register two as well.

document
	"namespace" identifier ";" *import 1*member

import
	"use" identifier ";"

member
	unit ";"
	error ";"
	enum ";"
	interface ";"

unit
	"unit" word ["=" uint]

enum
	"enum" word "{" 1*enum-members "}"

enum-members
	word ","
	word "=" uint ","
	word "=" uint "<<" uint ","

error
	"error" word ["=" uint] [":" type]

interface
	"interface" word ["=" uint] ["::" parents] "{" *method "}"
	"interface" word "::" parents

parent
	identifier [","]
	identifier "," parent

method
	call
	send
	recv

call
	"call" word [cap-list] "(" [param-list] ")" result

send
	"send" word [cap-list] "(" [param-list] ")"

recv
	"recv" word [cap-list] "(" [param-list] ")"

cap-list
	"{" capabilities ["..."] [";" capabilities ["..."]] "}"

capabilities
	capability [","]
	capability "," capabilities

capability
	word
	word ":" identifier

param-list
	params ["..."]

params
	param [","]
	param "," params

param
	word ":" type

type
	enum-name
	"uint"
	"u8"
	"u16"
	"u32"
	"u64"
	"int"
	"i8"
	"i16"
	"i32"
	"i64"
	"size"
	"uintptr"

result
	result-type
	result-type "|" error-list

error-list
	error-type
	error-list "," error-type

error-type
	error-name
	error-name "::" "*"

result-type
	type
	unit-name
	enum-name
	"void"

options
	result-type ["|"]
	result-type "|" options

identifier
	word
	identifier "::" word

uint
	/[0-9]+/
	/0x[0-9a-zA-Z]+/
	/0o[0-8]+/
	/0b[01]+/
word
	/[a-zA-Z][a-zA-Z0-9_]*/
enum-name
	identifier
unit-name
	identifier
error-name
	identifier