A templating language that looks like Lisp and compiles to HTML
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tokenStream.js 364B

12345678910111213141516171819202122
  1. module.exports = class TokenStream {
  2. constructor() {
  3. this.tokens = []
  4. this.position = 0
  5. }
  6. advance() {
  7. this.position++
  8. }
  9. eat(tokenType) {
  10. if (this.peek() && this.peek().type === tokenType) {
  11. this.advance()
  12. return this.peek(-1)
  13. }
  14. return false
  15. }
  16. peek(step = 0) {
  17. return this.tokens[this.position + step]
  18. }
  19. }