Skip to content

Commit

Permalink
Merge pull request #373 from dictu-lang/develop
Browse files Browse the repository at this point in the history
Release 0.16.0
  • Loading branch information
Jason2605 authored Jan 14, 2021
2 parents b9c700b + 1c6caaf commit 5887524
Show file tree
Hide file tree
Showing 99 changed files with 2,479 additions and 773 deletions.
31 changes: 13 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,17 @@ jobs:
cmake -DCMAKE_BUILD_TYPE=Debug -B ./build
cmake --build ./build
./dictu tests/runTests.du | tee /dev/stderr | grep -q 'Total memory usage: 0'
test-windows-cmake:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019, windows-2016]

## Seems the MSVC compiler was updated on Actions and we are getting loads of compilation
## issues with what seems like standard library header files. While investigating windows
## compilation will be removed from Actions
#
# test-windows-cmake:
# name: Test on ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [windows-2019, windows-latest]
#
# steps:
# - uses: actions/checkout@v2
# - name: Make dictu and run tests (No HTTP No Linenoise)
# run: |
# cmake -DCMAKE_BUILD_TYPE=Debug -DDISABLE_HTTP=1 -DDISABLE_LINENOISE=1 -B build
# cmake --build build
# Debug\dictu.exe tests/runTests.du
steps:
- uses: actions/checkout@v2
- name: Make dictu and run tests (No HTTP No Linenoise)
run: |
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -DCICD=1 -DDISABLE_HTTP=1 -DDISABLE_LINENOISE=1 -B build
cmake --build build
Debug\dictu.exe tests/runTests.du
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2020 Jason Hall
Copyright (c) 2019-2021 Jason Hall

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: >-
color_scheme: "dictu" # Custom theme
logo: "/assets/images/dictu-logo/dictu-wordmark.svg"

version: "0.15.0"
version: "0.16.0"
github_username: dictu-lang
search_enabled: true

Expand Down
7 changes: 6 additions & 1 deletion docs/_includes/css/just-the-docs.scss.liquid
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
@charset "UTF-8";
{% if site.logo %}
$logo: "{{ site.logo | absolute_url }}";
{% endif %}
@import "./support/support";
@import "./color_schemes/{{ include.color_scheme }}";
@import "./color_schemes/light";
@import "./modules";
@media (prefers-color-scheme: dark) {
@import "./color_schemes/dark";
@import "./modules";
}
{% include css/custom.scss.liquid %}
29 changes: 10 additions & 19 deletions docs/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,18 @@

<script>
(()=>{

if(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
const cssFile = document.querySelector('[rel="stylesheet"]');
const originalCssRef = cssFile.getAttribute('href');
const darkModeCssRef = originalCssRef.replace('just-the-docs-default.css', 'just-the-docs-dark.css');
cssFile.setAttribute('href', darkModeCssRef);
if(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
let oldLink = document.getElementById('favicon');
let link = document.createElement('link');
link.id = 'favicon';
link.rel = 'shortcut icon';
link.href = '{{ "/assets/favicon-dark.png" | absolute_url }}';

document.documentElement.classList.add('dark-mode');

let oldLink = document.getElementById('favicon');
let link = document.createElement('link');
link.id = 'favicon';
link.rel = 'shortcut icon';
link.href = '{{ "/assets/favicon-dark.png" | absolute_url }}';

if (oldLink) {
document.head.removeChild(oldLink);
if (oldLink) {
document.head.removeChild(oldLink);
}
document.head.appendChild(link);
}
document.head.appendChild(link);
}

})()
</script>

Expand Down
2 changes: 0 additions & 2 deletions docs/_sass/color_schemes/dictu.scss

This file was deleted.

2 changes: 0 additions & 2 deletions docs/_sass/content.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@charset "UTF-8";

//
// Styles for rendered markdown in the .main-content container
//
Expand Down
8 changes: 6 additions & 2 deletions docs/_sass/custom/custom.scss
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ body {
background-size: auto 20px;
}

.dark-mode {
.nav-list-link {
color: #000000;
}

@media (prefers-color-scheme: dark) {
.site-logo {
filter: invert(1);
}

a {
.nav-list-link {
color: #ffffff;
}

Expand Down
4 changes: 3 additions & 1 deletion docs/docs/collections/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ myList.contains(10); // false
### list.join(string: delimiter -> optional)

To convert a list of elements to a string use `.join()` to concatenate elements together by a given delimiter.
If a delimiter is not supplied `", "` is the default.
If a delimiter is not supplied `", "` is the default. Attempting to join an empty list will return an empty string.

```cs
var myList = [1, 2, 3];
print(myList.join()); // "1, 2, 3"
print(myList.join("")); // "123"
print(myList.join("-")); // "1-2-3"
print([].join("delimiter")); // ""
```

### list.remove(value)
Expand Down
2 changes: 0 additions & 2 deletions docs/docs/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ nav_order: 6
| - | Subtracts the values on either side of the operator together | 10 - 10 |
| * | Multiplies the values on either side of the operator together | 10 * 2 |
| / | Divides the values on either side of the operator together. | 10 / 3 |
| ++ Prefix | Increments the value of a variable by 1 | ++x |
| \-\- Prefix | Decrements the value of a variable by 1 | \-\-x |
| % | Modulo of values on either side of the operator | 10 % 2 |
| ** | Exponent (power) of the values | 2 ** 2 |
| & | Bitwise AND of the values | 10 & 2 |
Expand Down
52 changes: 52 additions & 0 deletions docs/docs/standard-lib/process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: default
title: Process
nav_order: 12
parent: Standard Library
---

# Process
{: .no_toc }

## Table of contents
{: .no_toc .text-delta }

1. TOC
{:toc}

---

## Process

To make use of the Process module an import is required.

```cs
import Process;
```

### Process.exec(list)

Executing an external process can be done via `.exec`. Unlike `.run()` exec does not wait for the process
to finish executing, so it is only useful for circumstances where you wish to "fire and forget".

`.exec()` expects a list as a parameter which is the command and any arguments for the command as individual list elements, which all must be strings.
It will return a Result that unwraps to `nil` on success.

```cs
Process.exec(["ls", "-la"]);
```

### Process.run(list, boolean: captureOutput -> optional)

Similar to `.run()` except this **will** wait for the external process to finish executing.

`.run()` expects a list as a parameter which is the command and any arguments for the command as individual list elements,
and it will return a Result that unwraps to `nil` on success.

If the external process writes to stdout and you wish to capture the output you can pass an optional boolean argument to
`.run()`, this will instead make the Result unwrap to a string of the captured output.

```cs
Process.run(["ls", "-la"]).unwrap();
print(Process.run(["echo", "test"], true).unwrap()); // 'test'
```
23 changes: 21 additions & 2 deletions docs/docs/standard-lib/sockets.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ Create a new socket object given a socket type and socket family.
This will return a Result and unwrap to a new socket object in which the rest of the methods are ran on.

```cs
var socket = Socket.create(Socket.AF_INET, Sockket.SOCK_STREAM).unwrap();
var result = Socket.create(Socket.AF_INET, Socket.SOCK_STREAM);
if (!result.success()) {
print(result.unwrapError());
// ...
}

var socket = result.unwrap();
```

### socket.bind(string, number)
Expand All @@ -48,7 +54,20 @@ This will bind a given socket object to an IP and port number.
Returns a Result type and on success will unwrap to nil.

```cs
var result = socket.bind("host", 10);
var result = socket.bind("127.0.0.1", 1000);
if (!result.success()) {
print(result.unwrapError());
// ...
}
```

### socket.connect(string, number)

This will connect to a socket on a given host and IP.
Returns a Result type and on success will unwrap to nil.

```cs
var result = socket.connect("127.0.0.1", 1000);
if (!result.success()) {
print(result.unwrapError());
// ...
Expand Down
8 changes: 5 additions & 3 deletions docs/docs/standard-lib/sqlite.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: default
title: Sqlite
nav_order: 12
nav_order: 13
parent: Standard Library
---

Expand All @@ -19,6 +19,8 @@ parent: Standard Library
## Sqlite
To make use of the Sqlite module an import is required.

Note: Unlike SQLite and most other libraries, foreign keys **are** enabled by default when a connection is opened.

```js
import Sqlite;
```
Expand All @@ -30,8 +32,8 @@ This opens a connection to a SQLite database. Returns a Result type and on succe
Note: You can pass ":memory:" to open the SQLite database in memory rather than a file.

```cs
Sqlite.connect(":memory:");
Sqlite.connect("my/database/file.db");
Sqlite.connect(":memory:").unwrap();
Sqlite.connect("my/database/file.db").unwrap();
```

### sqlite.execute(string: query, list: arguments -> optional)
Expand Down
2 changes: 1 addition & 1 deletion examples/bubbleSort.du
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def bubbleSort(list) {
var sortedList = list.copy();

for (var i = 0; i < sortedList.len(); ++i) {
for (var i = 0; i < sortedList.len(); i += 1) {
for (var j = 0; j < sortedList.len() - 1; ++j) {
if (sortedList[j] > sortedList[j+1]) {
var temp = sortedList[j+1];
Expand Down
2 changes: 1 addition & 1 deletion examples/design-patterns/chain-of-responsibility.du
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DogHandler < BaseHandler {
def businessLogic(handler) {
var food = ["Nut", "Banana", "Coffee"];

for (var i = 0; i < food.len(); ++i) {
for (var i = 0; i < food.len(); i += 1) {
print("Who wants a: {}".format(food[i]));

var response = handler.handle(food[i]);
Expand Down
2 changes: 1 addition & 1 deletion examples/design-patterns/observer.du
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Publisher {
* Notify all subscribed observers
*/
notify() {
for (var i = 0; i < this.observers.len(); ++i) {
for (var i = 0; i < this.observers.len(); i += 1) {
this.observers[i].update();
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/factorial.du
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var amount = input("Enter a number: ").toNumber().unwrap();
var num = 1;

if (amount > 0) {
for (var i = 1; i < amount + 1; ++i) {
for (var i = 1; i < amount + 1; i += 1) {
num *= i;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/fizzBuzz.du
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for (var i = 1; i < 101; ++i) {
for (var i = 1; i < 101; i += 1) {
if (i % 15 == 0) {
print("FizzBuzz");
} else if (i % 3 == 0) {
Expand Down
2 changes: 1 addition & 1 deletion examples/isPalindrome.du
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def isPalindrome(arg) {
var len = arg.len();
for (var i = 0; i < len/2; ++i) {
for (var i = 0; i < len/2; i += 1) {
if (arg[i] != arg[len - 1 - i]) {
return false;
}
Expand Down
9 changes: 6 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set(libraries)
set(INCLUDE_DIR include/)

# Remove CLI files
list(FILTER sources EXCLUDE REGEX "(main|linenoise).c")
list(FILTER headers EXCLUDE REGEX "linenoise.h")
list(FILTER sources EXCLUDE REGEX "(main|linenoise|utf8).c")
list(FILTER headers EXCLUDE REGEX "(linenoise|utf8).h")

find_library(SQLITE_LIB SQLite3)
set(THREADS)
Expand Down Expand Up @@ -40,7 +40,10 @@ endif()

if(MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
set(CMAKE_C_FLAGS "/WX /W1")
# An issue on CI/CD with winbase.h producing C5105 warnings
if(NOT CICD)
set(CMAKE_C_FLAGS "/WX /W1")
endif()
set(CMAKE_C_FLAGS_DEBUG "/Zi")
set(CMAKE_C_FLAGS_RELEASE "/O2")
else()
Expand Down
4 changes: 3 additions & 1 deletion src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
set(DICTU_CLI_SRC main.c linenoise.c linenoise.h)
set(DICTU_CLI_SRC main.c linenoise.c linenoise.h encodings/utf8.c encodings/utf8.h)
set(DISABLE_LINENOISE OFF CACHE BOOL "Determines if the REPL uses linenoise. Linenoise requires termios.")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})

if(DISABLE_LINENOISE)
list(FILTER DICTU_CLI_SRC EXCLUDE REGEX "(linenoise|utf8)\.(c|h)")

add_compile_definitions(DISABLE_LINENOISE)
endif()

Expand Down
Loading

0 comments on commit 5887524

Please sign in to comment.