Add goroutines
This commit is contained in:
parent
e5b8521ba4
commit
836149ffc2
12
ast.go
12
ast.go
@ -268,6 +268,12 @@ func executeCmd(cmd *Command) error {
|
||||
return fmt.Errorf("%s: %s", Call.Pos, err)
|
||||
}
|
||||
}
|
||||
} else if cmd.Goroutines != nil {
|
||||
// For each function call
|
||||
for _, goroutine := range cmd.Goroutines {
|
||||
// Attempt to call function
|
||||
go CallFunction(goroutine.Call)
|
||||
}
|
||||
} else if cmd.Ifs != nil {
|
||||
// For each if statement
|
||||
for _, If := range cmd.Ifs {
|
||||
@ -316,6 +322,7 @@ type Command struct {
|
||||
RptLoops []*RptLoop `| @@`
|
||||
WhlLoops []*WhlLoop `| @@`
|
||||
Defs []*FuncDef `| @@`
|
||||
Goroutines []*Goroutine `| @@`
|
||||
Calls []*FuncCall `| @@ )`
|
||||
}
|
||||
|
||||
@ -352,6 +359,11 @@ type FuncCall struct {
|
||||
Args []*Arg `@@*`
|
||||
}
|
||||
|
||||
type Goroutine struct {
|
||||
Pos lexer.Position
|
||||
Call *FuncCall `"go" @@`
|
||||
}
|
||||
|
||||
// Arg stores arguments for function calls
|
||||
type Arg struct {
|
||||
Pos lexer.Position
|
||||
|
Loading…
Reference in New Issue
Block a user