M ast/ast.ha => ast/ast.ha +1 -0
@@ 28,6 28,7 @@ export type method = struct {
caps_out: []capability,
params: []param,
result: ipc_type,
+ errors: []str,
};
// The ABI type of a method.
M doc/grammar.txt => doc/grammar.txt +9 -3
@@ 130,14 130,20 @@ type
result
result-type
- "(" options ")"
+ 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
- error-name
- error-name "::" "*"
"void"
options
A hello.ipc => hello.ipc +12 -0
@@ 0,0 1,12 @@
+namespace hello;
+
+error nonzero;
+error invalid;
+
+interface hello {
+ call say_hello() void;
+
+ call add(a: uint, b: uint) uint;
+
+ call mustbezero(z: uint) void | nonzero, invalid;
+};
M parse/interface.ha => parse/interface.ha +4 -0
@@ 90,6 90,10 @@ fn method(lex: *lex::lexer) (ast::method | error) = {
meth.result = ipc_type(lex)?;
+ if (try(lex, ltok::PIPE)? is lex::token) {
+ abort(); // TODO
+ };
+
want(lex, ltok::SEMICOLON)?;
return meth;
};
M parse/type.ha => parse/type.ha +2 -1
@@ 1,6 1,7 @@
use ast;
use lex;
use lex::{ltok};
+use strings;
fn ipc_type(lex: *lex::lexer) (ast::ipc_type | error) = {
const tok = want(lex,
@@ 47,6 48,6 @@ fn ipc_type(lex: *lex::lexer) (ast::ipc_type | error) = {
case ltok::UINTPTR =>
return ast::ptype::UINTPTR;
case ltok::WORD =>
- abort(); // TODO
+ return strings::dup(tok.1 as str): ast::ipc_type;
};
};