2021-03-02 03:43:06 +00:00
|
|
|
package scpt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/alecthomas/participle/lexer"
|
|
|
|
"github.com/alecthomas/participle/lexer/stateful"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Create custom stateful regex lexer
|
|
|
|
var scptLexer = lexer.Must(stateful.NewSimple([]stateful.Rule{
|
2021-03-05 03:30:08 +00:00
|
|
|
{"Ident", `[a-zA-Z_]\w*`, nil},
|
2021-03-02 03:43:06 +00:00
|
|
|
{"String", `"[^"]*"`, nil},
|
|
|
|
{"Number", `(?:\d*\.)?\d+`, nil},
|
2021-03-08 19:21:50 +00:00
|
|
|
{"Punct", `[![@$&(){}\|:;"',.?]|]`, nil},
|
2021-03-02 03:43:06 +00:00
|
|
|
{"Whitespace", `[ \t\r\n]+`, nil},
|
2021-03-03 08:27:54 +00:00
|
|
|
{"Comment", `(###(.|\n)+###|#[^\n]+)`, nil},
|
2021-03-08 19:21:50 +00:00
|
|
|
{"Operator", `(>=|<=|>|<|==|!=)|[-+*%/^]`, nil},
|
2021-03-02 04:18:52 +00:00
|
|
|
}))
|