aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJJ2023-07-25 05:02:01 +0000
committerJJ2023-07-25 05:02:01 +0000
commitf2a8b4607de5d8832ba97be7d0222ed8e2ebea89 (patch)
tree8c4db8e31390aca1760e5ad3e4280632c4358439 /docs
parentf2b9a083814f2e91f13860ae4a239630ee50040c (diff)
docs: import module as name
Diffstat (limited to 'docs')
-rw-r--r--docs/MODULES.md2
-rw-r--r--docs/SYNTAX.md7
2 files changed, 7 insertions, 2 deletions
diff --git a/docs/MODULES.md b/docs/MODULES.md
index 2aa0333..d387e0a 100644
--- a/docs/MODULES.md
+++ b/docs/MODULES.md
@@ -40,6 +40,8 @@ When linked as a library, however, the file structure is not visible - and so on
Modules do not export everything in their scope: indeed, all identifiers within a module are **private by default**, and must be explicitly marked public by use of the `pub` keyword. In support of encapsulation, fields of types, too, are considered separate from the type itself and also must be `pub` to be accessible. Identifiers from imported modules, of course, are not considered part of the current module unless explicitly exported.
+Modules and identifiers from modules may be imported and exported `as` a different name.
+
```puck
```
diff --git a/docs/SYNTAX.md b/docs/SYNTAX.md
index ecf7c6d..5090d33 100644
--- a/docs/SYNTAX.md
+++ b/docs/SYNTAX.md
@@ -109,9 +109,12 @@ FOR_STMT ::= 'for' GROUP 'in' EXPR ':' STMT
## Modules
```
-IMPORT_STMT ::= 'import' IDENT? ('/' (IDENT | '[' (IDENT (',' IDENT)*)? ']'))*
-EXPORT_STMT ::= 'export' IDENT? ('/' (IDENT | '[' (IDENT (',' IDENT)*)? ']'))*
+IMPORT_STMT ::= 'import' IDENT_AS?
+ ('/' (IDENT_AS | '[' (IDENT_AS (',' IDENT_AS)*)? ']'))*
+EXPORT_STMT ::= 'export' IDENT_AS?
+ ('/' (IDENT_AS | '[' (IDENT_AS (',' IDENT_AS)*)? ']'))*
MODULE_STMT ::= 'module' IDENT ':' STMT
+IDENT_AS ::= IDENT ('as' IDENT)?
```
## Macros