Files
Linux.js---javascript-OS/rootfs overrides/usr/lib/sheebr/lexer.js
T
Marc 721c919c7b ChibraxOS 2
Changes:
- kernel 6.0.2
- Broken init scripts
- Switch to bun for better peroformance an easier ffi
- Removed grup
- Efi support without graphics (at least graphics werent tested)
- Suppression de toutes les dépendance non libc
- new splash
- broken audio
- typescript support
- ls rewritten to be more reliable
2022-10-22 13:47:33 +02:00

56 lines
1014 B
JavaScript

//@ts-check
export default class Lexer{
/**
* @param { string } source
*/
constructor(source){
/** @type { string[] } */
this.tokens = [];
this.current = 0;
this.start = 0;
this.source = source
}
scanTokens(){
while(this.current < this.source.length){
this.start = this.current
this.scanToken()
}
return this.tokens;
}
scanToken(){
if(this.source[this.current] == "\""){
this.string()
}
else{
let content = ""
while(this.source[this.current] != ' ' && this.source[this.current] != '\n' && this.current < this.source.length ){
content += this.source[this.current];
this.current++;
}
this.tokens.push(content)
}
this.current++;
}
string(){
this.current++;
let content = ""
while(this.source[this.current] != "\"" && this.current < this.source.length){
content += this.source[this.current];
this.current++;
}
this.tokens.push(content)
}
//addToken(tokenType, value=""){
// this.tokens.push(Token(tokenType, value))
//}
}