aboutsummaryrefslogtreecommitdiff
path: root/src/parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.y')
-rw-r--r--src/parser.y52
1 files changed, 12 insertions, 40 deletions
diff --git a/src/parser.y b/src/parser.y
index 7b2c651..6ec2eb2 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -73,7 +73,6 @@
%token IF "if"
%token ELSE "else"
%token NIL "nil"
-%token OWN "own"
%token PUB "pub"
%token MUT "mut"
%token CONTINUE "continue"
@@ -82,7 +81,6 @@
%token DOT "."
%token SCOPE "::"
%token FATARROW "=>"
-%token ERRARROW "!>"
%right "[" "]"
/* precedence */
@@ -101,10 +99,10 @@
%left "::"
%nterm <node> top unit proc proc_decl call closure var expr statement body
-%nterm <node> vars exprs statements closures err trailing_closure
-%nterm <node> opt_vars opt_exprs opt_statements opt_trailing_closure opt_err opt_error
+%nterm <node> vars exprs statements closures trailing_closure
+%nterm <node> opt_vars opt_exprs opt_statements opt_trailing_closure
%nterm <node> rev_vars rev_exprs rev_closures rev_statements
-%nterm <node> let if nil own unop binop construct import
+%nterm <node> let if nil unop binop construct import
%nterm <node> struct struct_cont trait
%nterm <node> type_param type_params opt_type_params
@@ -346,29 +344,20 @@ closures
}
}
-err
- : "!>" ID body {
- $$ = gen_err_branch($2, $3, src_loc(@$));
- }
-
-opt_err
- : err
- | { $$ = NULL; }
-
call
- : expr "(" opt_exprs ")" ";" opt_err {
- $$ = gen_call($1, $[opt_exprs], $[opt_err], src_loc(@$));
+ : expr "(" opt_exprs ")" ";" {
+ $$ = gen_call($1, $[opt_exprs], src_loc(@$));
}
- | expr "(" opt_exprs ")" "=>" opt_vars ";" opt_err {
+ | expr "(" opt_exprs ")" "=>" opt_vars ";" {
/* the rest of the function body is our closure, gets fixed up
* later */
struct ast *closure = gen_closure($[opt_vars], NULL, src_loc(@$));
ast_append(&$[opt_exprs], closure);
- $$ = gen_call($[expr], $[opt_exprs], $[opt_err], src_loc(@$));
+ $$ = gen_call($[expr], $[opt_exprs], src_loc(@$));
}
- | expr "(" opt_exprs ")" closures opt_err {
+ | expr "(" opt_exprs ")" closures {
ast_append(&$[opt_exprs], $[closures]);
- $$ = gen_call($[expr], $[opt_exprs], $[opt_err], src_loc(@$));
+ $$ = gen_call($[expr], $[opt_exprs], src_loc(@$));
}
let
@@ -384,26 +373,11 @@ nil
$$ = gen_nil($2, $3, $5, src_loc(@$));
}
-own
- : "own" ID body {
- $$ = gen_own($2, $3, src_loc(@$));
- }
-
-opt_error
- : "error" STRING {
- $$ = gen_error($2, NULL, src_loc(@$));
- }
- | "error" ID {
- $$ = gen_error(NULL, gen_id($2, src_loc(@$)), src_loc(@$));
- }
- | { $$ = NULL; }
-
statement
: call
| body
| let
| nil
- | own
| if
| ";" { $$ = gen_empty(src_loc(@$)); }
@@ -419,8 +393,8 @@ opt_statements
| { $$ = NULL; }
body
- : "{" opt_statements opt_error "}" {
- $$ = gen_block($2, $3, src_loc(@$));
+ : "{" opt_statements "}" {
+ $$ = gen_block($2, src_loc(@$));
}
behaviour
@@ -481,18 +455,16 @@ trait
import
: "import" STRING {
- $$ = gen_import($2, src_loc(@$));
+ $$ = gen_import(strip($2), src_loc(@$));
}
top
: proc
- | proc_decl
| struct
| struct_cont
| import
| trait
| "pub" proc { $$ = $2; ast_set_flags($$, AST_FLAG_PUBLIC); }
- | "pub" proc_decl { $$ = $2; ast_set_flags($$, AST_FLAG_PUBLIC); }
| "pub" struct { $$ = $2; ast_set_flags($$, AST_FLAG_PUBLIC); }
| "pub" struct_cont { $$ = $2; ast_set_flags($$, AST_FLAG_PUBLIC); }
| "pub" import { $$ = $2; ast_set_flags($$, AST_FLAG_PUBLIC); }