rename module to target

To avoid potential confusion with Rust modules,
gaybuild's modules are now called targets.
main
anna 2 years ago
parent 30273b7902
commit 7b7cd933d3
Signed by: fef
GPG Key ID: EC22E476DC2D3D84

@ -10,7 +10,7 @@ use std::io;
enum Scope {
File,
Module,
Target,
DepList,
SourceList,
}
@ -44,7 +44,7 @@ impl Parser {
while let Some(result) = self.lexer.next() {
let token = result?;
let node = match token.kind {
token::Kind::ModuleKeyword => self.parse_module(),
token::Kind::TargetKeyword => self.parse_target(),
token::Kind::SetKeyword => self.parse_set_expr(),
_ => self.syntax_error(format!("Unexpected token {}", token.kind), &token),
}?;
@ -57,8 +57,8 @@ impl Parser {
})
}
fn parse_module(&mut self) -> Result<tree::Node, Error> {
self.scope.push(Scope::Module);
fn parse_target(&mut self) -> Result<tree::Node, Error> {
self.scope.push(Scope::Target);
let name_token = self.lexer.expect_kind(token::Kind::Ident)?;
self.lexer.expect_kind(token::Kind::OBrace)?;
@ -79,7 +79,7 @@ impl Parser {
}
self.scope.pop();
Ok(tree::Node::Module {
Ok(tree::Node::Target {
name: Box::new(tree::Node::Ident(name_token.raw)),
content: children,
})

@ -28,7 +28,7 @@ pub enum Node {
name: Box<Node>,
val: Box<Node>,
},
Module {
Target {
name: Box<Node>,
content: Vec<Node>,
},
@ -74,7 +74,7 @@ impl Node {
name.visit(cb, depth);
val.visit(cb, depth);
}
Node::Module { name, content } => {
Node::Target { name, content } => {
name.visit(cb, depth);
for n in content {
n.visit(cb, depth);
@ -110,7 +110,7 @@ impl fmt::Display for Node {
Node::BinaryExpr { op, lhs, rhs } => op.raw(),
Node::TypeExpr(_) => "type",
Node::SetExpr { name, val } => "set",
Node::Module { name, content } => "module",
Node::Target { name, content } => "target",
Node::File { name, content } => "file",
}
)

@ -32,9 +32,9 @@ const fn kw(raw: &'static str, kind: token::Kind) -> KeywordMap {
static KEYWORDS: [KeywordMap; 6] = [
kw("depend", token::Kind::DependKeyword),
kw("include", token::Kind::IncludeKeyword),
kw("module", token::Kind::ModuleKeyword),
kw("set", token::Kind::SetKeyword),
kw("source", token::Kind::SourceKeyword),
kw("target", token::Kind::TargetKeyword),
kw("type", token::Kind::TypeKeyword),
];

@ -41,7 +41,7 @@ pub enum Kind {
DependKeyword,
IncludeKeyword,
ModuleKeyword,
TargetKeyword,
SetKeyword,
SourceKeyword,
TypeKeyword,
@ -74,9 +74,9 @@ impl fmt::Display for Kind {
Kind::DependKeyword => "keyword",
Kind::IncludeKeyword => "keyword",
Kind::ModuleKeyword => "keyword",
Kind::SetKeyword => "keyword",
Kind::SourceKeyword => "keyword",
Kind::TargetKeyword => "keyword",
Kind::TypeKeyword => "keyword",
Kind::StringLiteral => "string",

@ -1,34 +1,34 @@
# the set keyword sets a property of the current scope
# (i.e. the entire build script, a module, etc.)
# (i.e. the entire build script, a target, etc.)
set RUSTC_EXE = "rustc";
set ASM_EXE = "clang";
set CC_EXE = "clang";
set LINK_EXE = "ld.lld";
set BUILD_PREFIX = "build";
# a module is a single compile target.
# modules can depend on other modules.
module kern {
# the type keyword defines whether the module is supposed to be
# a target is a single component.
# targets can depend on other targets.
target kern {
# the type keyword defines whether the target is supposed to be
# compiled into an executable binary (exe) or a library (lib).
type exe;
# the depend keyword adds one or more dependencies to the module.
# the depend keyword adds one or more dependencies to the target.
depend [
libk,
arch,
];
# the source keyword adds one or more source files to the module.
# the source keyword adds one or more source files to the target.
# the file extension determines what language/compiler to use.
source "kern/lib.rs";
}
module libk {
target libk {
type lib;
depend arch;
source "libk/lib.rs";
}
module arch {
target arch {
type lib;
source [
"arch/lib.rs",

Loading…
Cancel
Save