scpt/lexer.go

18 lines
496 B
Go
Raw Normal View History

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