move registration of token
replace homemade stack with SplStack