Implement functions, arrays, maps, and while loops. Document and clean up code.
This commit is contained in:
18
lexer.go
18
lexer.go
@@ -1,3 +1,17 @@
|
||||
/*
|
||||
Copyright (c) 2021 Arsen Musayelyan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
*/
|
||||
|
||||
package scpt
|
||||
|
||||
import (
|
||||
@@ -7,10 +21,10 @@ import (
|
||||
|
||||
// Create custom stateful regex lexer
|
||||
var scptLexer = lexer.Must(stateful.NewSimple([]stateful.Rule{
|
||||
{"Ident", `[a-zA-Z]\w*`, nil},
|
||||
{"Ident", `[a-zA-Z_]\w*`, nil},
|
||||
{"String", `"[^"]*"`, nil},
|
||||
{"Number", `(?:\d*\.)?\d+`, nil},
|
||||
{"Punct", `[-[!@$&()_{}\|:;"',.?/]|]`, nil},
|
||||
{"Punct", `[-[!@$&(){}\|:;"',.?/]|]`, nil},
|
||||
{"Whitespace", `[ \t\r\n]+`, nil},
|
||||
{"Comment", `(###(.|\n)+###|#[^\n]+)`, nil},
|
||||
{"Operator", `(>=|<=|>|<|==|!=)|[-+*/^%]`, nil},
|
||||
|
||||
Reference in New Issue
Block a user