Implement if statements and regex lexer
This commit is contained in:
17
lexer.go
Normal file
17
lexer.go
Normal file
@@ -0,0 +1,17 @@
|
||||
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},
|
||||
{"Punct", `[-[!@#$&()_{}\|:;"',.?/]|]`, nil},
|
||||
{"Whitespace", `[ \t\r\n]+`, nil},
|
||||
{"Comment", `#[^\n]+`, nil},
|
||||
{"Operator", `(>=|<=|>|<|==|!=)|[-+*/^%]`, nil},
|
||||
}))
|
||||
Reference in New Issue
Block a user