ajout de Sheebr + support de shutdown + auto install kernel

This commit is contained in:
Marc
2021-11-27 13:51:55 +01:00
parent a40aa1c153
commit 7480c8efc8
30 changed files with 1743 additions and 45 deletions
+57
View File
@@ -0,0 +1,57 @@
const { isAlpha } = require('./utils')
class Lexer{
constructor(source){
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))
}
}
module.exports = {
Lexer
}