42 lines
671 B
Go
42 lines
671 B
Go
|
package scpt
|
||
|
|
||
|
type AST struct {
|
||
|
Commands []*Command `@@*`
|
||
|
}
|
||
|
|
||
|
type Command struct {
|
||
|
Vars []*Var `( @@`
|
||
|
Calls []*FuncCall `| @@ )`
|
||
|
}
|
||
|
|
||
|
type FuncCall struct {
|
||
|
Name string `@Ident`
|
||
|
Args []*Arg `@@*`
|
||
|
}
|
||
|
|
||
|
type Arg struct {
|
||
|
Key string `"with" @Ident`
|
||
|
Value *Value `@@`
|
||
|
}
|
||
|
|
||
|
type Var struct {
|
||
|
Key string `"set" @Ident "to"`
|
||
|
Value *Value `@@`
|
||
|
}
|
||
|
|
||
|
type Value struct {
|
||
|
String *string ` @String`
|
||
|
Float *float64 `| @Float`
|
||
|
Integer *int64 `| @Int`
|
||
|
Bool *Bool `| @("true" | "false")`
|
||
|
SubCmd *FuncCall `| "(" @@ ")"`
|
||
|
VarVal *string `| "$" @Ident`
|
||
|
}
|
||
|
|
||
|
type Bool bool
|
||
|
|
||
|
func (b *Bool) Capture(values []string) error {
|
||
|
*b = values[0] == "true"
|
||
|
return nil
|
||
|
}
|