From f2a8b4607de5d8832ba97be7d0222ed8e2ebea89 Mon Sep 17 00:00:00 2001 From: JJ Date: Mon, 24 Jul 2023 22:02:01 -0700 Subject: docs: import module as name --- docs/MODULES.md | 2 ++ docs/SYNTAX.md | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'docs') 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 -- cgit v1.2.3-70-g09d2