mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
can now convert builtin calls to markup
This commit is contained in:
parent
c322d11e2a
commit
45df20cb17
4 changed files with 20 additions and 13 deletions
|
@ -35,7 +35,7 @@ install-zig-llvm-valgrind-clippy-rustfmt:
|
||||||
RUN rustup component add rustfmt
|
RUN rustup component add rustfmt
|
||||||
# criterion
|
# criterion
|
||||||
RUN cargo install cargo-criterion
|
RUN cargo install cargo-criterion
|
||||||
# wasm
|
# editor
|
||||||
RUN apt -y install libxkbcommon-dev
|
RUN apt -y install libxkbcommon-dev
|
||||||
# sccache
|
# sccache
|
||||||
RUN apt -y install libssl-dev
|
RUN apt -y install libssl-dev
|
||||||
|
@ -106,7 +106,7 @@ test-all:
|
||||||
build-nightly-release:
|
build-nightly-release:
|
||||||
FROM +test-rust
|
FROM +test-rust
|
||||||
COPY --dir .git ./
|
COPY --dir .git ./
|
||||||
# version.txt is used by the CLI: roc version
|
# version.txt is used by the CLI: roc --version
|
||||||
RUN printf "nightly pre-release, built from commit " > version.txt
|
RUN printf "nightly pre-release, built from commit " > version.txt
|
||||||
RUN git log --pretty=format:'%h' -n 1 >> version.txt
|
RUN git log --pretty=format:'%h' -n 1 >> version.txt
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|
|
@ -30,10 +30,7 @@ use roc_ast::{
|
||||||
env::Env,
|
env::Env,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use roc_module::{
|
use roc_module::{module_err::ModuleResult, symbol::Interns};
|
||||||
module_err::ModuleResult,
|
|
||||||
symbol::{get_module_ident_ids, Interns},
|
|
||||||
};
|
|
||||||
|
|
||||||
// make Markup Nodes: generate String representation, assign Highlighting Style
|
// make Markup Nodes: generate String representation, assign Highlighting Style
|
||||||
pub fn expr2_to_markup<'a>(
|
pub fn expr2_to_markup<'a>(
|
||||||
|
@ -46,6 +43,9 @@ pub fn expr2_to_markup<'a>(
|
||||||
) -> ASTResult<MarkNodeId> {
|
) -> ASTResult<MarkNodeId> {
|
||||||
let ast_node_id = ASTNodeId::AExprId(expr2_node_id);
|
let ast_node_id = ASTNodeId::AExprId(expr2_node_id);
|
||||||
|
|
||||||
|
// for debugging
|
||||||
|
//println!("EXPR2 {:?}", expr2);
|
||||||
|
|
||||||
let mark_node_id = match expr2 {
|
let mark_node_id = match expr2 {
|
||||||
Expr2::SmallInt { text, .. }
|
Expr2::SmallInt { text, .. }
|
||||||
| Expr2::I128 { text, .. }
|
| Expr2::I128 { text, .. }
|
||||||
|
@ -112,8 +112,7 @@ pub fn expr2_to_markup<'a>(
|
||||||
mark_node_pool.add(call_node)
|
mark_node_pool.add(call_node)
|
||||||
}
|
}
|
||||||
Expr2::Var(symbol) => {
|
Expr2::Var(symbol) => {
|
||||||
let text = get_module_ident_ids(&interns.all_ident_ids, &env.home)?
|
let text = symbol.fully_qualified(interns, env.home);
|
||||||
.get_name_str_res(symbol.ident_id())?;
|
|
||||||
|
|
||||||
new_markup_node(
|
new_markup_node(
|
||||||
text.to_string(),
|
text.to_string(),
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::fmt;
|
||||||
|
|
||||||
/// This could be uppercase or lowercase, qualified or unqualified.
|
/// This could be uppercase or lowercase, qualified or unqualified.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub struct Ident(pub IdentStr); // Is IdentStr allowed to be pub?
|
pub struct Ident(pub IdentStr);
|
||||||
|
|
||||||
impl Ident {
|
impl Ident {
|
||||||
pub fn as_inline_str(&self) -> &IdentStr {
|
pub fn as_inline_str(&self) -> &IdentStr {
|
||||||
|
|
|
@ -151,16 +151,24 @@ main = "Hello, world!"
|
||||||
#[test]
|
#[test]
|
||||||
fn top_level_def_value() {
|
fn top_level_def_value() {
|
||||||
expect_html_def(
|
expect_html_def(
|
||||||
r#"myFunction = "Hello, World!""#,
|
r#"myVal = "Hello, World!""#,
|
||||||
"<span class=\"syntax-value\">myFunction</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-string\">\"Hello, World!\"</span>\n\n",
|
"<span class=\"syntax-value\">myVal</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-string\">\"Hello, World!\"</span>\n\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tld_list() {
|
fn tld_list() {
|
||||||
expect_html_def(
|
expect_html_def(
|
||||||
r#"myFunction = [ 1, 2, 3 ]"#,
|
r#"myVal = [ 1, 2, 3 ]"#,
|
||||||
"<span class=\"syntax-value\">myFunction</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-bracket\">[ </span><span class=\"syntax-number\">1</span><span class=\"syntax-comma\">, </span><span class=\"syntax-number\">2</span><span class=\"syntax-comma\">, </span><span class=\"syntax-number\">3</span><span class=\"syntax-bracket\"> ]</span>\n\n",
|
"<span class=\"syntax-value\">myVal</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-bracket\">[ </span><span class=\"syntax-number\">1</span><span class=\"syntax-comma\">, </span><span class=\"syntax-number\">2</span><span class=\"syntax-comma\">, </span><span class=\"syntax-number\">3</span><span class=\"syntax-bracket\"> ]</span>\n\n",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn call_builtin() {
|
||||||
|
expect_html_def(
|
||||||
|
r#"myVal = Str.fromInt 1234"#,
|
||||||
|
"<span class=\"syntax-value\">myVal</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-value\">Str.fromInt</span><span class=\"syntax-blank\"> </span><span class=\"syntax-number\">1234</span>\n\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue