Skip to content

Commit

Permalink
Rename capsules to components and keyword capsule to topmost
Browse files Browse the repository at this point in the history
Fixes #128.
  • Loading branch information
fmease committed Feb 14, 2022
1 parent 84c302a commit 991fe4d
Show file tree
Hide file tree
Showing 69 changed files with 839 additions and 819 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ No IDE is available yet. However basic syntax highlighting is available for Visu
## Generated API Documentation

As hinted in the help text (`./lushui -h`), you use `lushui doc` (and variations) to generate (HTML) documentation.
To view it, you currently need to manually do `<browser> build/doc/<capsule>/index.html`. In the future, you will be able
To view it, you currently need to manually do `<browser> build/doc/<component>/index.html`. In the future, you will be able
to just pass `--open` to `./lushui doc`.

By default, documentation comments are treated as plain text. However, the goal is to make AsciiDoc the standard markup language. Today, this is only opt-in via the _unstable_ option `-Z asciidoc` which requires [Asciidoctor](https://asciidoctor.org/) to be installed and available as `asciidoctor` (a custom installation path is not supported at the moment).
Expand Down
4 changes: 2 additions & 2 deletions bugs/exposure-reach-of-exposure-reach-neglected.lushui
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
;;; not sure how we can tackle this problem.

module inner =
use capsule.offside as remote
use topmost.offside as remote

module offside =
@(public capsule.inner.remote) module m = ;;; @Bug we should not be able to access `remote` here!!!
@(public topmost.inner.remote) module m = ;;; @Bug we should not be able to access `remote` here!!!

2 changes: 1 addition & 1 deletion libraries/core/source/bool.lushui
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ not (b: Bool): Bool =
false => true
true => false

use capsule.unit.(Unit Thunk (force as !))
use topmost.unit.(Unit Thunk (force as !))

@public
if (A: Type) (condition: Bool) (lazy consequent: Thunk A) (lazy alternate: Thunk A): A =
Expand Down
4 changes: 2 additions & 2 deletions libraries/core/source/int.lushui
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module
data Int: Type

;;; @public @intrinsic
;;; to-nat: Int -> Option capsule.nat.Nat
;;; to-nat: Int -> Option topmost.nat.Nat

;;; @public @intrinsic
;;; absolute: Int -> capsule.nat.Nat
;;; absolute: Int -> topmost.nat.Nat

6 changes: 3 additions & 3 deletions libraries/core/source/nat.lushui
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;; Natural numbers and related functions.
module

use capsule.(option.Option bool.Bool text.Text)
use topmost.(option.Option bool.Bool text.Text)

@public @intrinsic
data Nat: Type
Expand Down Expand Up @@ -75,7 +75,7 @@ greater-equal: Nat -> Nat -> Bool
@public @intrinsic
display: Nat -> Text

use capsule.(bool ordering)
use topmost.(bool ordering)

@public
compare (n: Nat) (m: Nat): ordering.Ordering =
Expand All @@ -86,4 +86,4 @@ compare (n: Nat) (m: Nat): ordering.Ordering =
bool.false => ordering.greater

;;; @public @intrinsic
;;; to-int: Nat -> capsule.int.Int
;;; to-int: Nat -> topmost.int.Int
4 changes: 2 additions & 2 deletions libraries/core/source/ordering.lushui
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ invert (o: Ordering): Ordering =
equal => equal
greater => less

use capsule.unit.(unit Unit Thunk (force as !))
use capsule.int.Int
use topmost.unit.(unit Unit Thunk (force as !))
use topmost.int.Int

@public
then (o: Ordering) (lazy p: Thunk Ordering): Ordering =
Expand Down
6 changes: 3 additions & 3 deletions libraries/core/source/reserved.lushui
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ data Underscore: Type of
@(doc-reserved-identifier "as")
data As: Type of

@(doc-reserved-identifier "capsule")
data Capsule: Type of

@(doc-reserved-identifier "case")
data Case: Type of

Expand Down Expand Up @@ -42,6 +39,9 @@ data Self: Type of
@(doc-reserved-identifier "super")
data Super: Type of

@(doc-reserved-identifier "topmost")
data Topmost: Type of

@(doc-reserved-identifier "Type")
data Type_: Type of

Expand Down
6 changes: 3 additions & 3 deletions libraries/core/source/tuple.lushui
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module

;;; @Question tuple backed by List or by Vector in core (or both implementations)?

use capsule.list.(List self)
use topmost.list.(List self)

;;; @Note backed by List
@public
Expand All @@ -15,8 +15,8 @@ data Tuple (L: List Type): Type of
@public
use Tuple.(empty cons)

use capsule.vector.(Vector self)
use capsule.nat.(Nat +)
use topmost.vector.(Vector self)
use topmost.nat.(Nat +)

;;; @Note backed by Vector
@public
Expand Down
2 changes: 1 addition & 1 deletion libraries/core/source/vector.lushui
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;; Homogeneous lists with a fixed length and related functions.
module

use capsule.nat.(Nat +)
use topmost.nat.(Nat +)

@public
data Vector (n: Nat) (A: Type): Type of
Expand Down
2 changes: 1 addition & 1 deletion misc/grammar/lushui.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Typed-Hole ::= "?" #Word

Path ::= Path-Head ("." Identifier)*
Path-Head ::= Path-Hanger | Identifier
Path-Hanger ::= "extern" | "capsule" | "super" | "self"
Path-Hanger ::= "extern" | "topmost" | "super" | "self"

Lambda-Literal ::= "\" Parameters Type-Annotation? "=>" Expression

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"keyword": {
"patterns": [
{
"match": "(?<![\\w\\-])(in|of|self|super|capsule|extern)(?![\\w\\-])",
"match": "(?<![\\w\\-])(in|of|self|super|topmost|extern)(?![\\w\\-])",
"name": "keyword.other.lushui"
},
{
Expand Down
42 changes: 21 additions & 21 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::{App, AppSettings, Arg};
use discriminant::Elements;
use lushui::{
diagnostics::{reporter::StderrReporter, Diagnostic},
package::CapsuleType,
package::ComponentType,
};

pub fn arguments() -> (Command, Options) {
Expand All @@ -17,22 +17,22 @@ pub fn arguments() -> (Command, Options) {
Arg::new("executable")
.long("executable")
.short('e')
.help("Creates an executable capsule in the package"),
.help("Creates an executable component in the package"),
Arg::new("library")
.long("library")
.short('l')
.help("Creates a library capsule in the package"),
.help("Creates a library component in the package"),
];

let build_options = [
Arg::new("no-core").long("no-core").help(
"Removes the dependency to the library `core` from the given single-file package",
),
Arg::new("capsule-type")
.long("capsule-type")
Arg::new("component-type")
.long("component-type")
.takes_value(true)
.possible_values(&["executable", "library"])
.help("Sets the capsule type of the given single-file package"),
.help("Sets the component type of the given single-file package"),
Arg::new("interpreter")
.long("interpreter")
.takes_value(true)
Expand Down Expand Up @@ -147,8 +147,8 @@ pub fn arguments() -> (Command, Options) {
options: BuildOptions {
path: matches.value_of_os("PATH").map(Into::into),
no_core: matches.is_present("no-core"),
capsule_type: matches
.value_of("capsule-type")
component_type: matches
.value_of("component-type")
.map(|input| input.parse().unwrap()),
interpreter: matches
.value_of("interpreter")
Expand All @@ -170,7 +170,7 @@ pub fn arguments() -> (Command, Options) {

GenerationOptions {
library,
// implicitly set when no explicit capsule type specified
// implicitly set when no explicit component type specified
executable: matches.is_present("executable") || !library,
}
},
Expand Down Expand Up @@ -308,7 +308,7 @@ pub enum BuildMode {
pub struct BuildOptions {
pub path: Option<PathBuf>,
pub no_core: bool,
pub capsule_type: Option<CapsuleType>,
pub component_type: Option<ComponentType>,
pub interpreter: Interpreter,
}

Expand Down Expand Up @@ -373,20 +373,20 @@ impl UnstableOption {
match self {
Self::Help => "Prints help information and halts",
Self::Internals => "Enables internal language and library features",
Self::EmitTokens => "Emits the tokens of the current capsule output by the lexer",
Self::EmitAst => "Emits the abstract syntax tree (AST) of the current capsule output by the parser",
Self::EmitLoweredAst => "Emits the lowered AST of the current capsule",
Self::EmitTokens => "Emits the tokens of the current component output by the lexer",
Self::EmitAst => "Emits the abstract syntax tree (AST) of the current component output by the parser",
Self::EmitLoweredAst => "Emits the lowered AST of the current component",
Self::EmitHir => {
"Emits the high-level intermediate representation (HIR) of the current capsule output by the resolver"
"Emits the high-level intermediate representation (HIR) of the current component output by the resolver"
}
Self::EmitUntypedScope => "Emits the untyped scope of the current capsule output by the resolver",
Self::EmitScope => "Emits the typed scope of the current capsule output by the typer",
Self::EmitUntypedScope => "Emits the untyped scope of the current component output by the resolver",
Self::EmitScope => "Emits the typed scope of the current component output by the typer",
Self::ShowIndices => "Shows the internal indices of bindings in other output or error messages",
Self::Durations => "Prints the duration of each pass through the current capsule",
Self::LexOnly => "Halts the execution after lexing the current capsule",
Self::ParseOnly => "Halts the execution after parsing the current capsule",
Self::LowerOnly => "Halts the execution after lowering the current capsule",
Self::ResolveOnly => "Halts the execution after resolving the names of the current capsule",
Self::Durations => "Prints the duration of each pass through the current component",
Self::LexOnly => "Halts the execution after lexing the current component",
Self::ParseOnly => "Halts the execution after parsing the current component",
Self::LowerOnly => "Halts the execution after lowering the current component",
Self::ResolveOnly => "Halts the execution after resolving the names of the current component",
Self::AsciiDoc => "Interprets documentation comments as AsciiDoc when generating documentation",
Self::LoremIpsum(_) => "Replaces the documentation of every declaration with `amount` paragraphs of Lorem Ipsum",
}
Expand Down
16 changes: 8 additions & 8 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) mod interpreter;

use crate::{
hir::{self, Declaration, DeclarationIndex, Expression, Number},
resolver::Capsule,
resolver::Component,
syntax::lowered_ast::attributes::AttributeName,
utility::HashMap,
};
Expand All @@ -36,18 +36,18 @@ struct Compiler<'a> {
// @Temporary
entry: Option<ChunkIndex>,
declaration_mapping: HashMap<DeclarationIndex, ChunkIndex>,
capsule: &'a Capsule,
component: &'a Component,
}

impl<'a> Compiler<'a> {
fn new(capsule: &'a Capsule) -> Self {
fn new(component: &'a Component) -> Self {
Self {
chunks: IndexMap::new(),
constants: Vec::new(),
lambda_amount: 0,
entry: None,
declaration_mapping: default(),
capsule,
component,
}
}

Expand Down Expand Up @@ -134,8 +134,8 @@ impl<'a> Compiler<'a> {
)?;
self.chunks[index].instructions.push(Instruction::Return);

// @Task obsolete once we map any CapsuleIndex to a chunk identifier
if self.capsule.program_entry.as_ref() == Some(&function.binder) {
// @Task obsolete once we map any ComponentIndex to a chunk identifier
if self.component.program_entry.as_ref() == Some(&function.binder) {
self.entry = Some(index);
}
}
Expand Down Expand Up @@ -273,9 +273,9 @@ pub enum CompilationError {}
// @Temporary
pub fn compile_and_interpret_declaration(
declaration: &Declaration,
capsule: &Capsule,
component: &Component,
) -> Result<(), Error> {
let mut compiler = Compiler::new(capsule);
let mut compiler = Compiler::new(component);
compiler.compile_declaration(declaration)?;
// dbg!(&compiler.chunks);
eprintln!("{}", compiler.print_chunks());
Expand Down
4 changes: 2 additions & 2 deletions src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ pub enum Code {
E024,
/// Invalid unnamed path hanger.
E025,
/// `capsule` or `super` inside nested path.
/// `topmost` or `super` inside nested path.
E026,
/// Attribute argument type mismatch.
E027,
Expand All @@ -668,7 +668,7 @@ pub enum Code {
E034,
/// Type analysis.
E035,
/// Invalid capsule name.
/// Invalid component name.
E036,
/// Exposure reach not an ancestor of definition-site namespace.
E037,
Expand Down
Loading

0 comments on commit 991fe4d

Please sign in to comment.