lang: Add edges to lexer and parser
This adds some initial syntax for external edges to the language. There are still improvements which are necessary for send/recv.
This commit is contained in:
14
examples/lang/edges0.mcl
Normal file
14
examples/lang/edges0.mcl
Normal file
@@ -0,0 +1,14 @@
|
||||
exec "exec0" {
|
||||
cmd => "sleep 10s",
|
||||
shell => "/bin/bash",
|
||||
}
|
||||
exec "exec1" {
|
||||
cmd => "sleep 10s",
|
||||
shell => "/bin/bash",
|
||||
}
|
||||
exec "exec2" {
|
||||
cmd => "sleep 10s",
|
||||
shell => "/bin/bash",
|
||||
}
|
||||
|
||||
Exec["exec0"] -> Exec["exec1"] -> Exec["exec2"]
|
||||
8
examples/lang/password0.mcl
Normal file
8
examples/lang/password0.mcl
Normal file
@@ -0,0 +1,8 @@
|
||||
password "pass0" {
|
||||
length => 8,
|
||||
}
|
||||
|
||||
file "/tmp/mgmt/password" {
|
||||
}
|
||||
|
||||
Password["pass0"].password -> File["/tmp/mgmt/password"].content
|
||||
9
examples/lang/sendrecv0.mcl
Normal file
9
examples/lang/sendrecv0.mcl
Normal file
@@ -0,0 +1,9 @@
|
||||
exec "exec0" {
|
||||
cmd => "echo hello world && echo goodbye world 1>&2", # to stdout && stderr
|
||||
shell => "/bin/bash",
|
||||
}
|
||||
|
||||
print "print0" {
|
||||
}
|
||||
|
||||
Exec["exec0"].output -> Print["print0"].msg
|
||||
14
examples/lang/sendrecv1.mcl
Normal file
14
examples/lang/sendrecv1.mcl
Normal file
@@ -0,0 +1,14 @@
|
||||
file "/tmp/mgmt/foo" {
|
||||
content => "hello from foo\n",
|
||||
}
|
||||
|
||||
print "print0" {
|
||||
}
|
||||
|
||||
File["/tmp/mgmt/foo"].content -> Print["print0"].msg
|
||||
|
||||
print "print1" {
|
||||
msg => "hello",
|
||||
}
|
||||
|
||||
Print["print0"] -> Print["print1"]
|
||||
8
examples/lang/sendrecv2.mcl
Normal file
8
examples/lang/sendrecv2.mcl
Normal file
@@ -0,0 +1,8 @@
|
||||
file "/tmp/mgmt/foo" {
|
||||
content => "hello from foo\n",
|
||||
}
|
||||
|
||||
file "/tmp/mgmt/bar" {
|
||||
}
|
||||
|
||||
File["/tmp/mgmt/foo"].content -> File["/tmp/mgmt/bar"].content
|
||||
21
examples/lang/sendrecv3.mcl
Normal file
21
examples/lang/sendrecv3.mcl
Normal file
@@ -0,0 +1,21 @@
|
||||
$ns = "estate"
|
||||
$exchanged = kvlookup($ns)
|
||||
$state = maplookup($exchanged, $hostname, "default")
|
||||
|
||||
exec "exec0" {
|
||||
cmd => "echo hello world && echo goodbye world 1>&2", # to stdout && stderr
|
||||
shell => "/bin/bash",
|
||||
}
|
||||
|
||||
kv "kv0" {
|
||||
key => $ns,
|
||||
#value => "two",
|
||||
}
|
||||
|
||||
Exec["exec0"].output -> Kv["kv0"].value
|
||||
|
||||
if $state != "default" {
|
||||
file "/tmp/mgmt/state" {
|
||||
content => printf("state: %s\n", $state),
|
||||
}
|
||||
}
|
||||
@@ -8,28 +8,43 @@ if $state == "one" || $state == "default" {
|
||||
file "/tmp/mgmt/state" {
|
||||
content => "state: one\n",
|
||||
}
|
||||
|
||||
exec "timer" {
|
||||
cmd => "/usr/bin/sleep 1s",
|
||||
}
|
||||
kv "${ns}" {
|
||||
key => $ns,
|
||||
value => "two",
|
||||
}
|
||||
Exec["timer"] -> Kv["${ns}"]
|
||||
}
|
||||
if $state == "two" {
|
||||
|
||||
file "/tmp/mgmt/state" {
|
||||
content => "state: two\n",
|
||||
}
|
||||
|
||||
exec "timer" {
|
||||
cmd => "/usr/bin/sleep 1s",
|
||||
}
|
||||
kv "${ns}" {
|
||||
key => $ns,
|
||||
value => "three",
|
||||
}
|
||||
Exec["timer"] -> Kv["${ns}"]
|
||||
}
|
||||
if $state == "three" {
|
||||
|
||||
file "/tmp/mgmt/state" {
|
||||
content => "state: three\n",
|
||||
}
|
||||
|
||||
exec "timer" {
|
||||
cmd => "/usr/bin/sleep 1s",
|
||||
}
|
||||
kv "${ns}" {
|
||||
key => $ns,
|
||||
value => "one",
|
||||
}
|
||||
Exec["timer"] -> Kv["${ns}"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user