@@ -12,3 +12,4 @@ void main() {
|
|||||||
puts("Hello, world!");
|
puts("Hello, world!");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
.
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Imports
|
||||||
|
The import statement allows one module access to the public declarations of another module.
|
||||||
|
|
||||||
|
## Syntax
|
||||||
|
The import statement uses the following syntax:
|
||||||
|
|
||||||
|
```c2
|
||||||
|
import module_name;
|
||||||
|
```
|
||||||
|
|
||||||
|
They can optionally be prefixed by the `public` keyword, in which case the module will
|
||||||
|
export everything in the import transitively.
|
||||||
|
|
||||||
|
For instance,
|
||||||
|
|
||||||
|
```c2
|
||||||
|
--- a.c2
|
||||||
|
module a;
|
||||||
|
import b;
|
||||||
|
|
||||||
|
--- b.c2
|
||||||
|
module b;
|
||||||
|
public import c;
|
||||||
|
|
||||||
|
--- c.c2
|
||||||
|
module c;
|
||||||
|
|
||||||
|
// Some declarations
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, both module a and b can access the declarations in module c.
|
||||||
@@ -4,11 +4,15 @@
|
|||||||
#ifndef AST_H
|
#ifndef AST_H
|
||||||
#define AST_H
|
#define AST_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/// @brief The name of the module being imported.
|
/// @brief The name of the module being imported.
|
||||||
char* module_name;
|
char* module_name;
|
||||||
|
|
||||||
|
/// @brief Whether the import is public or not.
|
||||||
|
bool is_public;
|
||||||
} ImportDeclaration;
|
} ImportDeclaration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user