Selaa lähdekoodia

Tokenizer will now only accept multi-line strings if the newline is preceeded by a backspace.

master
Bryan Miller 5 vuotta sitten
vanhempi
commit
908ba8852d
1 muutettua tiedostoa jossa 11 lisäystä ja 6 poistoa
  1. +11
    -6
      src/MOS/6502/assembler/tokenizer.js

+ 11
- 6
src/MOS/6502/assembler/tokenizer.js Näytä tiedosto

@@ -82,7 +82,7 @@ function isPunctuation(c){
}

function isOp(c){
return ("=+-/*#".indexOf(c) >= 0);
return ("=+-/*#<>!".indexOf(c) >= 0);
}


@@ -96,12 +96,12 @@ class Tokenizer{
this.__stream = GetTextStream(input);
}

genTokenObject(type, val){
genTokenObject(type, val, line, col){
return {
type: type,
val: val,
line: this.__stream.line(),
col: this.__stream.col()
line: (typeof(line) === 'number') ? line : this.__stream.line(),
col: (typeof(col) === 'number') ? col : this.__stream.col()
}
}

@@ -141,6 +141,9 @@ class Tokenizer{
readString(end){
var str = "";
var escaped = false;
var line = this.__stream.line();
var col = this.__stream.col();
console.log(line);
this.__stream.next();
while (!this.__stream.eof()){
let c = this.__stream.next();
@@ -149,13 +152,15 @@ class Tokenizer{
escaped = false;
} else if (c === "\\"){
escaped = true;
} else if (c === "\n"){
this.__stream.die("String terminated early.");
} else if (c === end){
break;
} else {
str += c;
}
}
return this.genTokenObject('string', str);
return this.genTokenObject('string', str, line, col);
}

readDirective(){
@@ -195,7 +200,7 @@ class Tokenizer{
} else if (isPunctuation(c)){
return this.genTokenObject('punc', this.__stream.next());
} else if (isOp(c)){
return this.genTokenObject('op', this.__stream.next());
return this.genTokenObject('op', this.readWhile(isOp));
}
this.__stream.die("Unable to process character '" + c + "'.");
}

Loading…
Peruuta
Tallenna