sunjay / brain

A high level programming language that compiles into the brainfuck esoteric programming language
MIT License
170 stars 12 forks source link

Modules #37

Open sunjay opened 7 years ago

sunjay commented 7 years ago

Must be implemented in tandem with: #59

Support the following syntax.

For declaring modules within a package.

// private module
mod motion;

// inline module
mod foo {
    // code for this module goes here
    // can refer to scope above using super
    use super::*;
    //pub blah = ...
}
// foo::blah can be used in this module

// Exposed as just modules since these are less often used and more sensible to access this way
pub mod screen;
pub mod shapes;
pub mod pen;

pub use motion::*;

For linking an external library:

// use package is a compound keyword specially used for linking
// It is only valid to use this statement in the root module for a package
use package something;

use something;
use something::foo;
use something as bar;
use something::foo as bar;
use something::{foo as bar, spam};
use something::{self, foo as bar, spam};
use something::*;

Implementation Notes