/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function TokenStream(iterator) {
  let done = false;
  function next() {
    if (done) {
      return void 0;
    }
    const n = iterator.next();
    if (n.done) {
      done = true;
    }
    return n.value;
  }
  return {
    token: next(),
    peeked: next(),
    get done() {
      return this.token === void 0;
    },
    next() {
      this.token = this.peeked;
      this.peeked = next();
    },
    get description() {
      switch (this.token?.type) {
        case void 0:
          return "end of statement";
        case "word":
          return `word "${this.token.value}"`;
        case "value":
          return `value "${this.token.value}"`;
        default:
          if (this.token?.type.match(/[a-z]/i)) {
            return `keyword "${this.token?.type}"`;
          }
          return `operator "${this.token?.type}"`;
      }
    }
  };
}
export {
  TokenStream
};
//# sourceMappingURL=TokenStream.js.map
