aboutsummaryrefslogtreecommitdiff
path: root/parser/statefunc.go
diff options
context:
space:
mode:
authorNeonXP <i@neonxp.dev>2022-11-16 05:11:19 +0300
committerNeonXP <i@neonxp.dev>2022-11-16 05:11:19 +0300
commita321bfe7b2f6db5078de7b2e5ed5ddcccd65f319 (patch)
treed11c187bceee610a7843463949df128569142680 /parser/statefunc.go
initial commit
Diffstat (limited to 'parser/statefunc.go')
-rw-r--r--parser/statefunc.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/parser/statefunc.go b/parser/statefunc.go
new file mode 100644
index 0000000..69d7098
--- /dev/null
+++ b/parser/statefunc.go
@@ -0,0 +1,17 @@
+package parser
+
+type stateFunc func(*lexer) stateFunc
+
+type stateStack []stateFunc
+
+func (ss *stateStack) Push(s stateFunc) {
+ *ss = append(*ss, s)
+}
+
+func (ss *stateStack) Pop() (s stateFunc) {
+ if len(*ss) == 0 {
+ return nil
+ }
+ *ss, s = (*ss)[:len(*ss)-1], (*ss)[len(*ss)-1]
+ return s
+}