ref: 7e94001f96f9c1f05af4be980ef8c25cea6b1342
parent: e559a7dc5f76558ea0f56d9bf26385b04b496bd4
author: Ori Bernstein <[email protected]>
date: Tue Feb 19 09:01:04 EST 2013
Allow empty package names. This exports the symbols into the main namespace.
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -125,7 +125,7 @@
%type <tylist> typelist typarams
%type <nodelist> typaramlist
-%type <tok> asnop cmpop addop mulop shiftop
+%type <tok> asnop cmpop addop mulop shiftop optident
%type <tydef> tydef typeid
@@ -216,11 +216,17 @@
{$$ = mkuse($1->line, $2->str, 1);}
;
-package : Tpkg Tident Tasn pkgbody Tendblk
+optident: Tident {$$ = $1;}
+ | /* empty */ {$$ = NULL;}
+ ;
+
+package : Tpkg optident Tasn pkgbody Tendblk
{if (file->file.exports->name)
fatal($1->line, "Package already declared\n");
- updatens(file->file.exports, $2->str);
- updatens(file->file.globls, $2->str);
+ if ($2) {
+ updatens(file->file.exports, $2->str);
+ updatens(file->file.globls, $2->str);
+ }
}
;
--- a/test/exportmain.myr
+++ b/test/exportmain.myr
@@ -1,5 +1,7 @@
+use std
+
pkg =
- foo : (val:int -> int)
+ const foo : (val:int -> int)
;;