From a321bfe7b2f6db5078de7b2e5ed5ddcccd65f319 Mon Sep 17 00:00:00 2001 From: NeonXP Date: Wed, 16 Nov 2022 05:11:19 +0300 Subject: initial commit --- parser/statefunc.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 parser/statefunc.go (limited to 'parser/statefunc.go') 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 +} -- cgit v1.2.3