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

One-liners connections sugar #533

Merged
merged 23 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c34847c
feat(parser,examples): add chainable connections syntax, also update …
emil14 Mar 22, 2024
0130b21
refactor(stdlib): massive renaming to function-like naming convention
emil14 Mar 27, 2024
95966ce
feat(parser): chain connections
emil14 Mar 27, 2024
c71b28a
fix(parser,examples,e2e): fix parsing connections after adding chains…
emil14 Apr 2, 2024
19ebc2c
wip(examples): keep fixing after refactoring (renamings) in stdlib
emil14 Apr 3, 2024
60d2930
refactor(parser:grammar): connections
emil14 Apr 5, 2024
7238435
wip/fix: massive fixes in compiler and runtime, 99 bottles compiles a…
emil14 Apr 5, 2024
2adc0b5
fix(examples): 99 bottles verbose is working again
emil14 Apr 5, 2024
f1ea482
refactor(examples:99:verbose): sync port naming with with_chain version
emil14 Apr 5, 2024
3455766
tmp
emil14 Apr 6, 2024
774b62d
fix(example): do not use chained connection inside deferred because t…
emil14 Apr 6, 2024
ac7aed5
Merge branch 'main' into new_sugar2
emil14 Apr 6, 2024
c1eb041
fix(examples): fixes after renaming in stdlib
emil14 Apr 6, 2024
74233c0
fix(stdlib:regexp): use right runtime func name
emil14 Apr 6, 2024
87b65dc
fix(examples,e2e): uncomment fizzbuzz example
emil14 Apr 6, 2024
6695dac
fix(std:x): scanln runtime func name
emil14 Apr 6, 2024
410cff0
fix(e2e): std naming
emil14 Apr 7, 2024
b28f6f5
fix(runtime:funcs:mod): outport name
emil14 Apr 7, 2024
a9bcd85
fix(e2e): order dependend with array inport
emil14 Apr 7, 2024
fd31a97
Merge branches 'new_sugar2' and 'main' of github.com:nevalang/neva
emil14 Apr 7, 2024
c575553
fix(examples,runtime): fixes after renamings
emil14 Apr 7, 2024
24e9c1a
fix(examples): use fixed version of dep, the one without recursive co…
emil14 Apr 7, 2024
8878477
refactor(examples): just remove comments (fixme moved to issue)
emil14 Apr 7, 2024
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
37 changes: 32 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@
"mode": "auto",
"program": "${workspaceFolder}/cmd/neva",
"cwd": "${workspaceFolder}/examples",
"args": ["run", "3_interfaces"]
"args": ["run", "3_interfaces/verbose"]
},
{
"name": "Neva CLI 31",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/neva",
"cwd": "${workspaceFolder}/examples",
"args": ["run", "3_interfaces/with_imports"]
},
{
"name": "Neva CLI 40",
Expand Down Expand Up @@ -223,10 +232,28 @@
"mode": "auto",
"program": "${workspaceFolder}/cmd/neva",
"cwd": "${workspaceFolder}/examples",
"args": ["run", "11_99_bottles"]
"args": ["run", "11_99_bottles/verbose"]
},
{
"name": "Neva CLI 111",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/neva",
"cwd": "${workspaceFolder}/examples",
"args": ["run", "11_99_bottles/with_chain"]
},
{
"name": "TMP",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/neva",
"cwd": "${workspaceFolder}/e2e/tmp",
"args": ["run", "-debug", "main"]
},
{
"name": "Neva CLI 113",
"name": "Neva CLI 130",
"type": "go",
"request": "launch",
"mode": "auto",
Expand All @@ -235,7 +262,7 @@
"args": ["run", "13_fizzbuzz"]
},
{
"name": "Neva CLI 114",
"name": "Neva CLI 140",
"type": "go",
"request": "launch",
"mode": "auto",
Expand All @@ -244,7 +271,7 @@
"args": ["run", "14_list_index"]
},
{
"name": "Neva CLI 115",
"name": "Neva CLI 150",
"type": "go",
"request": "launch",
"mode": "auto",
Expand Down
6 changes: 3 additions & 3 deletions e2e/comments/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ component Main(start) (stop) {
// comment inside component 1
nodes {
// comment inside nodes 1
Printer<any>
Println<any>
// comment inside nodes 2
}
// comment inside component 2
net {
// comment inside network 1
:start -> printer:data
:start -> println:data
// comment inside network 2
printer:sig -> :stop
println:sig -> :stop
// comment inside network
}
// comment inside component 3
Expand Down
6 changes: 3 additions & 3 deletions e2e/conn_with_only_port_addr/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

const array list<int> = [1,2,3]
component Main(start any) (stop any) {
nodes { printer Printer<any>}
nodes { println Println<any>}
net {
:start -> ($array -> printer:data)
printer:sig
:start -> ($array -> println:data)
println:sig
}
}
2 changes: 1 addition & 1 deletion e2e/incompat_comp_type_arg/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
component Main(start) (stop) {
nodes { Decrementor<any> }
nodes { Decr<any> }
net {
:start -> (42 -> decrementor:data)
decrementor:res -> :stop
Expand Down
6 changes: 3 additions & 3 deletions e2e/list_with_neg_nums/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const l list<int> = [-215]

component Main(start) (stop) {
nodes { Printer<any> }
nodes { Println<any> }
net {
:start -> ($l -> printer:data)
printer:sig -> :stop
:start -> ($l -> println:data)
println:sig -> :stop
}
}
14 changes: 7 additions & 7 deletions e2e/order_dependend_with_arr_inport/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
component Main(start) (stop) {
nodes {
Printer<int>
sub PortBridge<int> { handler Subtractor<int> }
Println<int>
sub PortReducer<int> { reducer Sub<int> }
}
net {
:start -> (
1 -> sub:ports[0],
2 -> sub:ports[1],
3 -> sub:ports[2]
1 -> sub:port[0],
2 -> sub:port[1],
3 -> sub:port[2]
)
sub:res -> printer:data
printer:sig -> :stop
sub:res -> println:data
println:sig -> :stop
}
}
6 changes: 3 additions & 3 deletions e2e/print_float/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const x float = 42

component Main(start) (stop) {
nodes { Printer<float> }
nodes { Println<float> }
net {
:start -> ($x -> printer:data)
printer:sig -> :stop
:start -> ($x -> println:data)
println:sig -> :stop
}
}
6 changes: 3 additions & 3 deletions e2e/struct_selector_on_port_addr/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
component Main(start) (stop) {
nodes {
Foo
Printer<int>
Println<int>
}
net {
:start -> foo:sig
foo:msg.a -> printer:data
printer:sig -> :stop
foo:msg.a -> println:data
println:sig -> :stop
}
}

Expand Down
10 changes: 5 additions & 5 deletions examples/10_regex_submatch/main.neva
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { regexp }

component Main(start) (stop) {
nodes { Printer<any>, regexp.Submatcher }
nodes { Println<any>, regexp.Submatch }
net {
:start -> (
'a(x*)b(y|z)c' -> submatcher:regexp,
'-axxxbyc-' -> submatcher:data
'a(x*)b(y|z)c' -> submatch:regexp,
'-axxxbyc-' -> submatch:data
)
submatcher:res -> printer:data
printer:sig -> :stop
submatch:res -> println:data
println:sig -> :stop
}
}
83 changes: 0 additions & 83 deletions examples/11_99_bottles/main.neva

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
)

func Test(t *testing.T) {
err := os.Chdir("../")
err := os.Chdir("../..")
require.NoError(t, err)

wd, err := os.Getwd()
require.NoError(t, err)
defer os.Chdir(wd)

cmd := exec.Command("neva", "run", "11_99_bottles")
cmd := exec.Command("neva", "run", "11_99_bottles/verbose")

out, err := cmd.CombinedOutput()
require.NoError(t, err)
Expand Down
83 changes: 83 additions & 0 deletions examples/11_99_bottles/verbose/main.neva
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// https://www.99-bottles-of-beer.net

component Main(start) (stop) {
nodes { Match<int>, next PrintNext2Lines }
net {
:start -> (99 -> next:n)

next:n -> match:data
-1 -> match:case[0]

match:case[0] -> :stop
match:else -> next:n
}
}

component PrintNext2Lines(n int) (n int) {
nodes {
decr Decr<int>
first PrintFirstLine
second PrintSecondLine
}
net {
:n -> first:n
first:n -> decr:n
decr:n -> second:n
second:n -> :n
}
}

// === First Line ===

const {
firstLine1 string = '$0 bottles of beer on the wall, $0 bottles of beer.\n'
firstLine2 string = '1 bottle of beer on the wall, 1 bottle of beer.'
firstLine3 string = 'No more bottles of beer on the wall, no more bottles of beer.'
}

component PrintFirstLine(n int) (n int) {
nodes { Match<int>, Println<string>, Printf<int>, Lock<int> }
net {
:n -> [match:data, lock:data]
0 -> match:case[0]
1 -> match:case[1]

match:case[0] -> ($firstLine3 -> println:data)
match:case[1] -> ($firstLine2 -> println:data)
match:else -> printf:args[0]
$firstLine1 -> printf:tpl

println:sig -> lock:sig
printf:args[0] -> lock:sig

lock:data -> :n
}
}

// === Second Line ===

const {
secondLine1 string = 'Take one down and pass it around, $0 bottles of beer on the wall.\n\n'
secondLine2 string = 'Take one down and pass it around, 1 bottle of beer on the wall.\n'
secondLine3 string = 'Take one down and pass it around, no more bottles of beer on the wall.\n'
secondLine4 string = 'Go to the store and buy some more, 99 bottles of beer on the wall.'
}

component PrintSecondLine(n int) (n int) {
nodes { Match<int>, Lock<int>, Printf<int>, Println<string> }
net {
:n -> [match:data, lock:data]
-1 -> match:case[0]
0 -> match:case[1]
1 -> match:case[2]

match:case[0] -> ($secondLine4 -> println:data)
match:case[1] -> ($secondLine3 -> println:data)
match:case[2] -> ($secondLine2 -> println:data)
match:else -> printf:args[0]
$secondLine1 -> printf:tpl

[println:sig, printf:args[0]] -> lock:sig
lock:data -> :n
}
}
Loading
Loading