Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playground #7

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/specification/characters_letters_digits.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
There are a few predefined rules that could not easily be written as valid
EBNF or are used multiple times and therefor defined here to avoid repeating
them. The EBNF rules for the identifiers `unicode_*` are written within
comments as there is no real way to define them otherways.
There are a few predefined rules that could not easily be written as valid EBNF
or are used multiple times and therefor defined here to avoid repeating them.
The EBNF rules for the identifiers `unicode_*` are written within comments as
there is no real way to define them otherways.

```EBNF
unicode_any = // any Unicode code point
Expand Down
16 changes: 8 additions & 8 deletions docs/specification/expressions.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
An expression in _Whistle_ evaluates to a value, this could be through either [binary](#binary) or
[unary expressions](#unary), or the special [conditional expression](#conditional).
An expression in _Whistle_ evaluates to a value, this could be through either
[binary](#binary) or [unary expressions](#unary), or the special
[conditional expression](#conditional).

> In the future, once [PR #21](https://github.com/whistle-lang/whistle/pull/21) gets merged, there
> will be a new type of expression: that of the array slice and index accessors.
> In the future, once [PR #21](https://github.com/whistle-lang/whistle/pull/21)
> gets merged, there will be a new type of expression: that of the array slice
> and index accessors.

## Unary

A unary expression can be one of two things, either a primary or an operation.

### Primary

> TODO, Probably move this to a new file
Due to the complexity and many different types of primary expressions the
specification for them can be found [here](./primary_expressions).

### Operation

Expand Down
35 changes: 19 additions & 16 deletions docs/specification/literals.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Literals are one of the essential parts of any program, they express values and one of the possible
building blocks of an [expression](./expressions).
Literals are one of the essential parts of any program, they express values and
one of the possible building blocks of an [expression](./expressions).

In _Whistle_ there are six literal types: booleans, integers, floats, characters, strings and the
none literal.
In _Whistle_ there are six literal types: booleans, integers, floats,
characters, strings and the none literal.

```EBNF
literal = bool_literal
Expand All @@ -15,18 +15,19 @@ literal = bool_literal

## Booleans

Booleans represent a true or false value, it does this through the keywords `true` and `false`.
Booleans represent a true or false value, it does this through the keywords
`true` and `false`.

```EBNF
bool_literal = "true" | "false"
```

## Integers

Integers represent a whole number in either binary, octal, decimal or hexadecimal base. Integer
literals are always positive/unsigned numbers, but this does not mean _Whistle_ only supports
unsigned integers, instead to use signed integers one would use the [negate](./operators#unary)
operator.
Integers represent a whole number in either binary, octal, decimal or
hexadecimal base. Integer literals are always positive/unsigned numbers, but
this does not mean _Whistle_ only supports unsigned integers, instead to use
signed integers one would use the [negate](./operators#unary) operator.

```EBNF
int_literal = int_literal_binary
Expand All @@ -41,10 +42,11 @@ int_literal_hex = "0" , ( "x" | "X" ) , { digit_hex }

## Floating point numbers

The float literal represents an [ieee754](https://en.wikipedia.org/wiki/IEEE_754) floating point
number. This number can contain an optional fractional part and or exponent along with the whole
part. Once again to negate the float literal one would use the [negate](./operators#unary)
operator.
The float literal represents an
[ieee754](https://en.wikipedia.org/wiki/IEEE_754) floating point number. This
number can contain an optional fractional part and or exponent along with the
whole part. Once again to negate the float literal one would use the
[negate](./operators#unary) operator.

```EBNF
float_literal = { digit_decimal } , [ float_decimal ] , [ float_exponent ]
Expand All @@ -54,9 +56,10 @@ float_exponent = ( "e" | "E" ) , [ "+" | "-" ] , { digit_decimal }

## Characters and strings

The character literal represents a single unicode character while a string represents an sequence
of these unicode characters. There are certain escaped values for things like newlines, tabs and
null bytes. These escaped values apply for both the inner values of strings and characters.
The character literal represents a single unicode character while a string
represents an sequence of these unicode characters. There are certain escaped
values for things like newlines, tabs and null bytes. These escaped values apply
for both the inner values of strings and characters.

```EBNF
escaped_value = "\" , (""" | "\" | "r" | "n" | "t" | "0" | "'")
Expand Down
Empty file.
3 changes: 2 additions & 1 deletion docs/toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"title": "Characters, letters and digits"
},
"literals": { "title": "Literals" },
"expressions": { "title": "Expressions" }
"expressions": { "title": "Expressions" },
"primary_expressions": { "title": "Primary Expressions" }
}
}
}
6 changes: 6 additions & 0 deletions www/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"denoland.vscode-deno",
"sastan.twind-intellisense"
]
}
5 changes: 5 additions & 0 deletions www/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"deno.enable": true,
"deno.lint": true,
"editor.defaultFormatter": "denoland.vscode-deno"
}
11 changes: 11 additions & 0 deletions www/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# fresh project

### Usage

Start the project:

```
deno task start
```

This will watch the project directory and restart as necessary.
9 changes: 2 additions & 7 deletions www/client_deps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
export * from "https://raw.githubusercontent.com/lucacasonato/fresh/main/runtime.ts";
import { IS_BROWSER } from "https://raw.githubusercontent.com/lucacasonato/fresh/main/runtime.ts";
import { apply, setup, tw } from "https://esm.sh/[email protected]";
export { apply, setup, tw };
if (IS_BROWSER) {
setup({});
}
export * from "https://raw.githubusercontent.com/load1n9/whistle_bindgen/main/lib.ts";
export { default as wabt } from "https://esm.sh/[email protected]?target=esnext";
10 changes: 3 additions & 7 deletions www/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/** @jsx h */

import { h, tw } from "../client_deps.ts";

export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
// deno-lint-ignore no-explicit-any
export function RoundedButton(props: any) {
return (
<button
{...props}
class={tw
`p-3 border border-transparent rounded-full text-white bg-indigo(600 hover:700) focus:(outline-none ring(2 offset-2 indigo-500)) disabled:(bg-indigo-200 cursor-default)`}
class={`p-3 border border-transparent rounded-full text-white bg-indigo(600 hover:700) focus:(outline-none ring(2 offset-2 indigo-500)) disabled:(bg-indigo-200 cursor-default)`}
/>
);
}
19 changes: 8 additions & 11 deletions www/components/DocsSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/** @jsx h */

import { apply, h, tw } from "../client_deps.ts";
import {
CATEGORIES,
TableOfContentsCategory,
Expand All @@ -9,26 +6,26 @@ import {

export default function DocsSidebar(props: { path: string }) {
return (
<ol class={tw`list-decimal list-inside font-semibold` + " nested"}>
<ol class={`list-decimal list-inside font-semibold` + " nested"}>
{CATEGORIES.map((category) => (
<SidebarCategory path={props.path} category={category} />
))}
</ol>
);
}

const link = apply`text(gray-900 hover:gray-600)`;
const linkActive = apply`text(blue-600 hover:blue-500)`;
const link = `text(gray-900 hover:gray-600)`;
const linkActive = `text(blue-600 hover:blue-500)`;

export function SidebarCategory(props: {
path: string;
category: TableOfContentsCategory;
}) {
const outerItem = tw`my-2 block`;
const innerList = tw`pl-4 list-decimal` + " nested";
const outerItem = `my-2 block`;
const innerList = `pl-4 list-decimal` + " nested";

const { title, href, entries } = props.category;
const outerLink = tw`${href == props.path ? linkActive : link} font-bold`;
const outerLink = `${href == props.path ? linkActive : link} font-bold`;

return (
<li class={outerItem}>
Expand All @@ -48,10 +45,10 @@ export function SidebarEntry(props: {
path: string;
entry: TableOfContentsCategoryEntry;
}) {
const innerItem = tw`my-0.5`;
const innerItem = `my-0.5`;

const { title, href } = props.entry;
const innerLink = tw`${href == props.path ? linkActive : link} font-normal`;
const innerLink = `${href == props.path ? linkActive : link} font-normal`;
return (
<li class={innerItem}>
<a href={href} class={innerLink}>{title}</a>
Expand Down
Loading