Skip to content

Commit

Permalink
feat(web): update simple example and made new code.png screenshot wit…
Browse files Browse the repository at this point in the history
…h codesnap
  • Loading branch information
emil14 committed Jan 29, 2024
1 parent 809164b commit 1f0242f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
3 changes: 2 additions & 1 deletion examples/0_do_nothing/main.neva
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Program that does literally nothing.
// This is the smallest possible program that compiles.
// It literally does absolutely literally nothing.
// Here we learn components, ports, networks, connections and port addrs.

components {
Expand Down
Binary file modified web/assets/code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions web/syntaxes/neva.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"match": "\\berror\\b",
"name": "storage.type.error"
},
{
"match": "\\bstream\\b",
"name": "storage.type.stream"
},
{
"include": "#struct_type"
},
Expand Down
3 changes: 3 additions & 0 deletions web/syntaxes/neva.tmLanguage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ repository:
# error
- match: "\\berror\\b" # Matches the keyword 'error'
name: storage.type.error
# stream
- match: "\\bstream\\b" # Matches the keyword 'stream'
name: storage.type.stream
# struct
- include: "#struct_type"
# enum
Expand Down
52 changes: 24 additions & 28 deletions web/syntaxes/tests/simple.neva
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import {
std/io
github.com/emil14/nevatools
ws github.com/nevalang/websocket
std/strconv

@/my_lovely_mod/foo
@/my_lovely_mod/bar
@/my_lovely_mod/baz

github.com/nevalang/x
}

types {
Err error
Float float
Bool bool
pub Str string
Vec<T> []T
Arr<T Vec<int>> [512][]T
Union Float | Vec | Arr | Rec | Enum
Struct struct {
pub Num int | float
pub Primitive Num | string | bool
pub Users list<User>
User struct {
age int
name string
bestFriend struct {
Expand All @@ -24,38 +25,33 @@ types {
}

interfaces {
InterfacePrivate<T bool>(y T, x int) (z T)
pub InterfacePublic<T Union>(x int, y string) (z T)
IStreamHandler<T>(seq stream<T>) (res T)
pub IListStreamer<T>(l list<T>) (seq stream<T>)
}

const {
zero any nil
myTrue bool true
pi float 3.14
pub vec Vec<float> [pi, pi]
greet string "Hello, world!"
pub maybeInt maybe<int>
pub nums list<int>[1, 2, 3, 4, 5]
}

components {
Main(enter) (exit) {
Main(enter any) (exit any) {
nodes {
doer Doer<Float>
bypass Bypass<float>
printer Printer<float>
writer foo.FileWriter
}
net {
in.enter -> doer.x
doer.z -> out.exit
in:enter -> (pi -> bypass:foo)
bypass:bar -> [printer:msg, writer:msg]
printer:msg -> out:exit
}
}

pub Doer<T float>(x) (z T) {
nodes {
abstractNode InterfacePrivate
printer io.Print
}
net {
in.x -> printer.v
printer.v -> out.z
}
pub Bypass<T float>(foo T) (bar T) {
net { in.foo -> out.bar }
}
}

0 comments on commit 1f0242f

Please sign in to comment.