JSFiddle - React, Tailwind, and code Playground
by cahnory
JavaScript
var Lexer = function () {
this.init();
};
Lexer.prototype = {
cursor: 0,
string: '',
lexems: [],
init: function () {
this.cursor = 0;
this.string = '';
},
read: function () {
if (this.cursor < this.string.length) {
return this.string.charAt(this.cursor++);
}
return -1;
},
peek: function () {
if (this.cursor < this.string.length) {
return this.string.charAt(this.cursor);
}
return -1;
}
};
Lexer.langs = {};
Lexer.langs.ocss = {
d
}
var l = new Lexer();
l.string = 'abcdefgh';
console.log(l.peek(), l.read());