From c8315126612fa812485402a84014e6fcbba73ff9 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 12 Jul 2023 16:11:04 -0400 Subject: [PATCH] remove github.io site due to overlap with readme --- README.md | 9 ++++++ external.css | 78 ----------------------------------------------- index.html | 48 ----------------------------- site/build.mers | 57 ---------------------------------- site/index.html | 54 -------------------------------- site/welcome.mers | 52 ------------------------------- 6 files changed, 9 insertions(+), 289 deletions(-) delete mode 100755 external.css delete mode 100755 index.html delete mode 100755 site/build.mers delete mode 100755 site/index.html delete mode 100755 site/welcome.mers diff --git a/README.md b/README.md index 31cbb21..4ce4a5c 100755 --- a/README.md +++ b/README.md @@ -29,6 +29,15 @@ Mers is written in rust. If you have `cargo`, use the build script in `build_scr Now, create a new text file (or choose one from the examples) and run it: `mers `. +## Known Issues (only major ones) + +### Multithreading + +If a function is called from two threads, all local variables of that function are shared. +This doesn't affect builtin functions, and since functions usually don't take long to execute, +the change of anyone encountering this is low, but it's something to be aware of. +It's a simple fix in theory, but a lot of work to implement, which is why the bug isn't fixed yet. + ## Docs [intro](docs/intro.md) diff --git a/external.css b/external.css deleted file mode 100755 index 40b5af7..0000000 --- a/external.css +++ /dev/null @@ -1,78 +0,0 @@ -body { - color: white; - background-color: #200f21; -} -h1, h2, h3 { - text-align: center; -} -hr { - display: block; - height: 1px; - border: 0; - border-top: 1px solid #ccc; - margin: 1em 0; - padding: 0; -} - -.mers-code-snippet { - text-align: left; -} - -.container { - height: auto; - overflow: auto; -} -.container_left { - margin-left: 8%; - width: 20%; - margin-right: 5%; - float: left; - display: inline-block; -} -.container_center { - margin-left: 0.5%; - width: 30%; - margin-right: 0.5%; - border-style: dotted; - display: inline-block; -} -.container_left2 { - margin-left: 8%; - width: 50%; - margin-right: 5%; - float: left; - display: inline-block; -} -.container_right { - margin-left: 5%; - width: 20%; - margin-right: 8%; - float: right; - display: inline-block; -} -.container2_left { - margin-left: 8%; - width: 40%; - float: left; - display: inline-block; -} -.container2_right { - margin-right: 8%; - width: 40%; - float: right; - display: inline-block; -} - -.code-border { - border-style: double; -} -.textalign-center { - text-align: center; -} -.afterpagebreak { - width: 100%; - page-break-before: always; -} -.fullwide { - width: 100%; -} diff --git a/index.html b/index.html deleted file mode 100755 index aac53c8..0000000 --- a/index.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Mark :: mers - - -

Mers

-
-
-

-fn get_number_input(question string) {
println(question)
input := read_line()
// try to parse to an int, then a float.
in := match {
input.parse_int() n n
input.parse_float() n n
}
// 'in' has type int/float/[] because of the match statement
switch! in {
int/float in in
// replace [] with an appropriate error before returning
[] [] Err: "input was not a number."
}
// return type is int/float/Err(string)
}

answer := get_number_input("What is your favorite number?")

answer.debug() // type: int/float/Err(string)
// switch can be used to branch based on a variables type.
// switch! indicates that every possible type must be handled.
switch! answer {
int num {
println("Entered an integer")
num.debug() // type: int
}
float num {
println("Entered a decimal number")
num.debug() // type: float
}
Err(string) [] println("Input was not a number!")
}

// wait one second
sleep(1)

// function that returns an anonymous function (function object).
// anonymous functions can be used as iterators in for-loops.
fn square_numbers() {
i := 0
() {
&i = i + 1
i * i
}
}

for num square_numbers() {
println(num.to_string())
// once num is greater than 60, the loop stops.
num.gt(50)
}
-
-
- -

Mers types

-
-Mers uses a multiple-types system. -It keeps track of which types a variable could have -and constructs a type with that information. -
-For example, int/float can represent a number - int or float. -Optional types can be []/[t] - either nothing or one value (tuple with length 0 or 1). -Mers doesn't have null, it just has the empty tuple []. -
-

No exceptions, no crashes

-
-Errors in mers are passed as values. -Because of the type system, you are forced to handle them explicitly. -Mers will not crash in unexpected places, because the only way to crash -it is by using one of the assume*() functions (similar to unwrap()s). -
-
-
-
-

HTML preprocessor to help build this document written in mers:

-
-

-<!DOCTYPE html>
# This document will be processed by build.mers.
# Lines starting with hashtags are comments and will be ignored.
# Lines starting with dollar-signs insert special text.
# To escape this, put a space before the hashtag or dollar sign.
<head>
<meta charset=“UTF-8”>
<link rel="stylesheet" href="external.css">
<title>Mark :: mers</title>
</head>
<body>
<h1>Mers</h1>
<section class="container">
<section class="container_left2 code-border">
<pre><code class="mers-code-snippet">
$welcome_script
</code></pre>
</section>
<section class="container_right">
<image
alt="some picture related to mers (todo)"
src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////
width="100%" height="100%"
>
<h3>Mers types</h3>
<div>
Mers uses a multiple-types system.
It keeps track of which types a variable could have
and constructs a type with that information.
<br>
For example, <code>int/float</code> can represent a number - int or
Optional types can be <code>[]/[t]</code> - either nothing or one v
Mers doesn't have null, it just has the empty tuple <code>[]</code>
</div>
<h3>No exceptions, no crashes</h3>
<div>
Errors in mers are passed as values.
Because of the type system, you are forced to handle them explicitl
Mers will not crash in unexpected places, because the only way to c
it is by using one of the assume*() functions (similar to unwrap()s
</div>
</section>
</section>
<hr>
<h3>HTML preprocessor to help build this document written in mers:</h3>
<section class="container">
<pre class="container2_left"><code>
$index.html
</code></pre>
<pre class="container2_right"><code class="mers-code-snippet">
$build_script
</code></pre>
</section>
</body>

-

-#!/usr/bin/env mers

// helper functions

fn read_string(path string) {
bytes_to_string(fs_read(path).assume_no_enum()).assume_no_enum()
}
fn code_to_html(code string code_width_limit_chars int) {
out := ""
for line code.regex(".*").assume_no_enum() {
if code_width_limit_chars.gtoe(0).and(line.len().gt(code_width_limit_chars)) {
&line = line.substring(0 code_width_limit_chars)
}
&line = line
.replace("&" "&amp;")
.replace("<" "&lt;")
.replace(">" "&gt;")
&out = out.add(line.add("<br>"))
}
out
}

// data

index := read_string("index.html")

index_html := index.code_to_html(75)
build_script := read_string("build.mers").code_to_html(-1)
welcome_script := read_string("welcome.mers").code_to_html(-1)

// process index.html

out := ""
for line index.regex("\\S*.*").assume_no_enum() {
if line.starts_with("#") {
// comment, ignore
} else if line.starts_with("$") {
if line == "$welcome_script" {
&out = out + welcome_script
} else if line == "$build_script" {
&out = out + build_script
} else if line == "$index.html" {
&out = out + index_html
}
} else {
// remove spaces
loop {
if line.starts_with(" ") {
&line = line.substring(1)
} else {
true // break
}
}
&out = out + line + "\n"
}
}
fs_write("../index.html" string_to_bytes(out)).assume_no_enum()

-
- - diff --git a/site/build.mers b/site/build.mers deleted file mode 100755 index 5cae040..0000000 --- a/site/build.mers +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env mers - -// helper functions - -fn read_string(path string) { - bytes_to_string(fs_read(path).assume_no_enum()).assume_no_enum() -} -fn code_to_html(code string code_width_limit_chars int) { - out := "" - for line code.regex(".*").assume_no_enum() { - if code_width_limit_chars.gtoe(0).and(line.len().gt(code_width_limit_chars)) { - &line = line.substring(0 code_width_limit_chars) - } - &line = line - .replace("&" "&") - .replace("<" "<") - .replace(">" ">") - &out = out.add(line.add("
")) - } - out -} - -// data - -index := read_string("index.html") - -index_html := index.code_to_html(75) -build_script := read_string("build.mers").code_to_html(-1) -welcome_script := read_string("welcome.mers").code_to_html(-1) - -// process index.html - -out := "" -for line index.regex("\\S*.*").assume_no_enum() { - if line.starts_with("#") { - // comment, ignore - } else if line.starts_with("$") { - if line == "$welcome_script" { - &out = out + welcome_script - } else if line == "$build_script" { - &out = out + build_script - } else if line == "$index.html" { - &out = out + index_html - } - } else { - // remove spaces - loop { - if line.starts_with(" ") { - &line = line.substring(1) - } else { - true // break - } - } - &out = out + line + "\n" - } -} -fs_write("../index.html" string_to_bytes(out)).assume_no_enum() diff --git a/site/index.html b/site/index.html deleted file mode 100755 index 49adafa..0000000 --- a/site/index.html +++ /dev/null @@ -1,54 +0,0 @@ - -# This document will be processed by build.mers. -# Lines starting with hashtags are comments and will be ignored. -# Lines starting with dollar-signs insert special text. -# To escape this, put a space before the hashtag or dollar sign. - - - - Mark :: mers - - -

Mers

-
-
-

-$welcome_script
-      
-
-
- some picture related to mers (todo) -

Mers types

-
- Mers uses a multiple-types system. - It keeps track of which types a variable could have - and constructs a type with that information. -
- For example, int/float can represent a number - int or float. - Optional types can be []/[t] - either nothing or one value (tuple with length 0 or 1). - Mers doesn't have null, it just has the empty tuple []. -
-

No exceptions, no crashes

-
- Errors in mers are passed as values. - Because of the type system, you are forced to handle them explicitly. - Mers will not crash in unexpected places, because the only way to crash - it is by using one of the assume*() functions (similar to unwrap()s). -
-
-
-
-

HTML preprocessor to help build this document written in mers:

-
-

-$index.html
-    
-

-$build_script
-    
-
- diff --git a/site/welcome.mers b/site/welcome.mers deleted file mode 100755 index f61b2d2..0000000 --- a/site/welcome.mers +++ /dev/null @@ -1,52 +0,0 @@ -fn get_number_input(question string) { - println(question) - input := read_line() - // try to parse to an int, then a float. - in := match { - input.parse_int() n n - input.parse_float() n n - } - // 'in' has type int/float/[] because of the match statement - switch! in { - int/float in in - // replace [] with an appropriate error before returning - [] [] Err: "input was not a number." - } - // return type is int/float/Err(string) -} - -answer := get_number_input("What is your favorite number?") - -answer.debug() // type: int/float/Err(string) -// switch can be used to branch based on a variables type. -// switch! indicates that every possible type must be handled. -switch! answer { - int num { - println("Entered an integer") - num.debug() // type: int - } - float num { - println("Entered a decimal number") - num.debug() // type: float - } - Err(string) [] println("Input was not a number!") -} - -// wait one second -sleep(1) - -// function that returns an anonymous function (function object). -// anonymous functions can be used as iterators in for-loops. -fn square_numbers() { - i := 0 - () { - &i = i + 1 - i * i - } -} - -for num square_numbers() { - println(num.to_string()) - // once num is greater than 60, the loop stops. - num.gt(50) -} \ No newline at end of file