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)
|
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 {
|
} else if cmd.Ifs != nil {
|
||||||
// For each if statement
|
// For each if statement
|
||||||
for _, If := range cmd.Ifs {
|
for _, If := range cmd.Ifs {
|
||||||
@ -316,6 +322,7 @@ type Command struct {
|
|||||||
RptLoops []*RptLoop `| @@`
|
RptLoops []*RptLoop `| @@`
|
||||||
WhlLoops []*WhlLoop `| @@`
|
WhlLoops []*WhlLoop `| @@`
|
||||||
Defs []*FuncDef `| @@`
|
Defs []*FuncDef `| @@`
|
||||||
|
Goroutines []*Goroutine `| @@`
|
||||||
Calls []*FuncCall `| @@ )`
|
Calls []*FuncCall `| @@ )`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,6 +359,11 @@ type FuncCall struct {
|
|||||||
Args []*Arg `@@*`
|
Args []*Arg `@@*`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Goroutine struct {
|
||||||
|
Pos lexer.Position
|
||||||
|
Call *FuncCall `"go" @@`
|
||||||
|
}
|
||||||
|
|
||||||
// Arg stores arguments for function calls
|
// Arg stores arguments for function calls
|
||||||
type Arg struct {
|
type Arg struct {
|
||||||
Pos lexer.Position
|
Pos lexer.Position
|
||||||
|
Loading…
Reference in New Issue
Block a user