mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +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
|
||||
# criterion
|
||||
RUN cargo install cargo-criterion
|
||||
# wasm
|
||||
# editor
|
||||
RUN apt -y install libxkbcommon-dev
|
||||
# sccache
|
||||
RUN apt -y install libssl-dev
|
||||
|
@ -106,7 +106,7 @@ test-all:
|
|||
build-nightly-release:
|
||||
FROM +test-rust
|
||||
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 git log --pretty=format:'%h' -n 1 >> version.txt
|
||||
RUN cargo build --release
|
||||
|
|
|
@ -30,10 +30,7 @@ use roc_ast::{
|
|||
env::Env,
|
||||
},
|
||||
};
|
||||
use roc_module::{
|
||||
module_err::ModuleResult,
|
||||
symbol::{get_module_ident_ids, Interns},
|
||||
};
|
||||
use roc_module::{module_err::ModuleResult, symbol::Interns};
|
||||
|
||||
// make Markup Nodes: generate String representation, assign Highlighting Style
|
||||
pub fn expr2_to_markup<'a>(
|
||||
|
@ -46,6 +43,9 @@ pub fn expr2_to_markup<'a>(
|
|||
) -> ASTResult<MarkNodeId> {
|
||||
let ast_node_id = ASTNodeId::AExprId(expr2_node_id);
|
||||
|
||||
// for debugging
|
||||
//println!("EXPR2 {:?}", expr2);
|
||||
|
||||
let mark_node_id = match expr2 {
|
||||
Expr2::SmallInt { text, .. }
|
||||
| Expr2::I128 { text, .. }
|
||||
|
@ -112,8 +112,7 @@ pub fn expr2_to_markup<'a>(
|
|||
mark_node_pool.add(call_node)
|
||||
}
|
||||
Expr2::Var(symbol) => {
|
||||
let text = get_module_ident_ids(&interns.all_ident_ids, &env.home)?
|
||||
.get_name_str_res(symbol.ident_id())?;
|
||||
let text = symbol.fully_qualified(interns, env.home);
|
||||
|
||||
new_markup_node(
|
||||
text.to_string(),
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::fmt;
|
|||
|
||||
/// This could be uppercase or lowercase, qualified or unqualified.
|
||||
#[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 {
|
||||
pub fn as_inline_str(&self) -> &IdentStr {
|
||||
|
|
|
@ -151,16 +151,24 @@ main = "Hello, world!"
|
|||
#[test]
|
||||
fn top_level_def_value() {
|
||||
expect_html_def(
|
||||
r#"myFunction = "Hello, World!""#,
|
||||
"<span class=\"syntax-value\">myFunction</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-string\">\"Hello, World!\"</span>\n\n",
|
||||
r#"myVal = "Hello, World!""#,
|
||||
"<span class=\"syntax-value\">myVal</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-string\">\"Hello, World!\"</span>\n\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tld_list() {
|
||||
expect_html_def(
|
||||
r#"myFunction = [ 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",
|
||||
r#"myVal = [ 1, 2, 3 ]"#,
|
||||
"<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