Skip to main content

Module import_statement

Module import_statement 

Source
Expand description

Import statement parser (get).

Handles all four import forms in rl-lang:

// 1. single file module
get mymodule

// 2. file module with path
get mymodule::utils

// 3. stdlib function
get std::math::sin

// 4. named imports from a module or stdlib
get sin, cos from std::math
get add, sub from mymodule::utils

The first token after get and whether :: or from follows determines which StatementKind variant is produced:

syntaxkind
get modStatementKind::ImportFile
get mod::subStatementKind::ImportFile
get std::ns::fnStatementKind::Import
get fn, fn from std::nsStatementKind::Import
get fn, fn from mod::subStatementKind::ImportFileNamed