A templating language that looks like Lisp and compiles to HTML
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

tokenStream.js 571B

1234567891011121314151617181920212223242526272829303132
  1. const OsloError = require('./osloError')
  2. module.exports = class TokenStream {
  3. constructor() {
  4. this.tokens = []
  5. this.position = 0
  6. }
  7. advance() {
  8. this.position++
  9. }
  10. eat(tokenType) {
  11. let token = this.peek()
  12. if (token && token.type === tokenType) {
  13. this.advance()
  14. return token
  15. }
  16. this.error = new OsloError({
  17. line: token.line,
  18. message: `Encountered an unexpected ${
  19. token.type
  20. } while looking for a ${tokenType}.`,
  21. })
  22. }
  23. peek(step = 0) {
  24. return this.tokens[this.position + step]
  25. }
  26. }