Skip to content

Commit

Permalink
Merge pull request #476 from nevalang/enums
Browse files Browse the repository at this point in the history
feat(parser): add syntax for enum const literals
  • Loading branch information
emil14 committed Mar 1, 2024
2 parents 9199587 + b871020 commit c56c154
Show file tree
Hide file tree
Showing 33 changed files with 2,082 additions and 1,693 deletions.
9 changes: 9 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@
"cwd": "${workspaceFolder}/examples",
"args": ["run", "7_struct_selector/verbose"]
},
{
"name": "Neva CLI 80",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/cli",
"cwd": "${workspaceFolder}/examples",
"args": ["run", "8_enums"]
},
// === LSP ===
{
"name": "LSP",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Nevalang programs are executable dataflow graphs with components connected throu
- Interpreter Mode
- Builtin Dependency Injection
- Builtin Observability
- Package Management
- Garbage Collection

Please note that even though these features are technically implemented, **developer-experience may be bad** due to current project state. **No backward-compatibility** guarantees at the time.
Expand Down
23 changes: 23 additions & 0 deletions examples/3_interfaces/simple/main.neva
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
interface IPrinter<T>(data T) (sig T)

component {
Main(start any) (stop any) {
nodes {
subNode SecondComponent {
depNode Printer<any>
}
}
net {
:start -> subNode:msg
subNode:msg -> :stop
}
}

SecondComponent (msg any) (msg any) {
nodes { depNode IPrinter<any> }
net {
:msg -> depNode:data
depNode:sig -> :msg
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
github.com/nevalang/x:main
}
import { github.com/nevalang/x:main }

interface IPrinter<T>(data T) (sig T)

Expand Down
1 change: 0 additions & 1 deletion examples/4_add_numbers/verbose/main.neva
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// FIXME def conns
component Main(start any) (stop any) {
nodes {
adder Adder<int>
Expand Down
4 changes: 1 addition & 3 deletions examples/5_add_real_numbers/with_sub_components/main.neva
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Here we learn how to simplify program by separating concerns

import {
x
}
import { x }

component {
Main(start any) (stop any) {
Expand Down
25 changes: 25 additions & 0 deletions examples/8_enums/main.neva
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
component Main(start any) (stop any) {
nodes { DayPrinter }
net {
:start -> (Day::Monday -> dayPrinter:day)
dayPrinter:sig -> :stop
}
}

type Day enum {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}

component DayPrinter(day Day) (sig any) {
nodes { Printer<Day> }
net {
:day -> printer:data
printer:sig -> :sig
}
}
Loading

0 comments on commit c56c154

Please sign in to comment.