This commit is contained in:
@@ -18,8 +18,6 @@ pub fn gather(instructions: List(definition.Instruction)) -> Information {
|
||||
_ -> Error(Nil)
|
||||
}
|
||||
})
|
||||
echo pushes
|
||||
|
||||
let min_max = case pushes {
|
||||
[] -> Error(Nil)
|
||||
[first, ..rest] ->
|
||||
|
||||
+29
-15
@@ -11,8 +11,6 @@ pub fn luma_markdown(
|
||||
information: helpers.Information,
|
||||
contents: String,
|
||||
) -> String {
|
||||
echo contents
|
||||
echo information
|
||||
let lines = string.split(contents, "\n")
|
||||
|
||||
let parsed =
|
||||
@@ -37,7 +35,7 @@ pub fn luma_markdown(
|
||||
definition.Truth(instruction) ->
|
||||
string.repeat("__", instruction)
|
||||
}
|
||||
definition.Pop(instruction) -> "##"
|
||||
definition.Pop(_) -> "##"
|
||||
}
|
||||
}),
|
||||
"",
|
||||
@@ -53,21 +51,37 @@ pub fn main() -> Nil {
|
||||
[filename] -> {
|
||||
case simplifile.read(filename) {
|
||||
Ok(contents) -> {
|
||||
//programm goes here
|
||||
let instructins = parser.handler(contents)
|
||||
let information = case instructins {
|
||||
// get informations
|
||||
definition.TextInstructions(instruction) ->
|
||||
helpers.gather(instruction)
|
||||
}
|
||||
echo information
|
||||
let result = luma_markdown(information, contents)
|
||||
io.println(result)
|
||||
render(contents)
|
||||
}
|
||||
Error(_) -> {
|
||||
io.println("Couldn't read file: " <> filename)
|
||||
Nil
|
||||
}
|
||||
Error(_) -> io.println("Couldn't read file")
|
||||
}
|
||||
}
|
||||
_ -> io.println("Usage: gleam run <file>")
|
||||
[] -> render(read_stdin([]))
|
||||
_ -> {
|
||||
io.println("Usage: luma_markdown [file]")
|
||||
Nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render(contents: String) -> Nil {
|
||||
let information = case parser.handler(contents) {
|
||||
definition.TextInstructions(instructions) -> helpers.gather(instructions)
|
||||
}
|
||||
let result = luma_markdown(information, contents)
|
||||
io.println(result)
|
||||
}
|
||||
|
||||
@external(erlang, "luma_stdin", "read_line")
|
||||
fn read_line() -> String
|
||||
|
||||
fn read_stdin(lines: List(String)) -> String {
|
||||
let line = read_line()
|
||||
case line {
|
||||
"" -> lines |> list.reverse |> string.join("")
|
||||
_ -> read_stdin([line, ..lines])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
-module(luma_stdin).
|
||||
|
||||
-export([read_line/0]).
|
||||
|
||||
read_line() ->
|
||||
case io:get_line("") of
|
||||
eof -> <<>>;
|
||||
Line -> unicode:characters_to_binary(Line)
|
||||
end.
|
||||
Reference in New Issue
Block a user