2021-03-01 19:43:06 -08: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-04 19:30:08 -08:00
|
|
|
{"Ident", `[a-zA-Z_]\w*`, nil},
|
2021-03-01 19:43:06 -08:00
|
|
|
{"String", `"[^"]*"`, nil},
|
|
|
|
|
{"Number", `(?:\d*\.)?\d+`, nil},
|
2021-03-08 11:21:50 -08:00
|
|
|
{"Punct", `[![@$&(){}\|:;"',.?]|]`, nil},
|
2021-03-01 19:43:06 -08:00
|
|
|
{"Whitespace", `[ \t\r\n]+`, nil},
|
2021-03-03 00:27:54 -08:00
|
|
|
{"Comment", `(###(.|\n)+###|#[^\n]+)`, nil},
|
2021-03-08 11:21:50 -08:00
|
|
|
{"Operator", `(>=|<=|>|<|==|!=)|[-+*%/^]`, nil},
|
2021-03-01 20:18:52 -08:00
|
|
|
}))
|