12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{ErrorHandler as e}from"./error-handler.js";import{Scanner as r}from"./scanner.js";import{Syntax as n,TokenNames as t}from"./types.js";class s{constructor(n,t){this.errorHandler=new e,this.errorHandler.tolerant=!!t&&("boolean"==typeof t.tolerant&&t.tolerant),this.scanner=new r(n,this.errorHandler),this.trackComments=!!t&&("boolean"==typeof t.comment&&t.comment),this.buffer=[]}errors(){return this.errorHandler.errors}getNextToken(){if(0===this.buffer.length){const e=this.scanner.scanComments();if(this.trackComments&&e&&e.forEach((e=>{const r=this.scanner.source.slice(e.start,e.end),t={type:e.multiLine?n.BlockComment:n.LineComment,value:r,range:e.range,loc:e.loc};this.buffer.push(t)})),!this.scanner.eof()){const e={line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},r=this.scanner.lex(),n={line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},s={type:t[r.type],value:this.scanner.source.slice(r.start,r.end),range:[r.start,r.end],loc:{start:e,end:n}};this.buffer.push(s)}}return this.buffer.shift()}}export{s as Tokenizer};
|