return tokens;
- },
+ }
/**
* findPuncToken - find the id of a token (previous to current)
n--;
}
return -1;
- },
+ }
/**
* lastSym - find the last token symbol
* need to back check syntax..
* @arg {Number} offset where to start..
* @return {Token} the token
*/
- public Token lastSym(TokenArray tokens, int n) {
+ public Token lastSym(TokenArray tokens, int n)
+ {
for (var i = n-1; i >= 0; i--) {
if (!(tokens.get(i).is("WHIT") || tokens.get(i).is("COMM"))) {
return tokens.get(i);
}
}
return null;
- },
+ }
/**
@returns {Boolean} Was the token found?
*/
- public bool read_word (TokenStream stream, TokenArray tokens) {
- var found = "";
- while (!stream.look().eof && Lang.isWordChar(stream.look())) {
+ public bool read_word (TokenStream stream, TokenArray tokens)
+ {
+ string found = "";
+ while (!stream.lookEOF() && Lang.isWordChar(stream.look())) {
found += stream.next();
}
- if (found === "") {
+ if (found == "") {
return false;
}
- var name;
- if ((name = Lang.keyword(found))) {
- if (found == 'return' && tokens.lastSym().data == ')') {
+ var name = Lang.keyword(found);
+ if (name != null) {
+
+ // look for "()return" ?? why ???
+
+ if (found == "return" && tokens.lastSym().data == ")") {
//Seed.print('@' + tokens.length);
- var n = this.findPuncToken(tokens, ')');
+ var n = this.findPuncToken(tokens, ")");
//Seed.print(')@' + n);
- n = this.findPuncToken(tokens, '(', n-1);
+ n = this.findPuncToken(tokens, "(", n-1);
//Seed.print('(@' + n);
var lt = this.lastSym(tokens, n);
- print(JSON.stringify(lt));
- if (lt.type != 'KEYW' || ['IF', 'WHILE'].indexOf(lt.name) < -1) {
+
+ //print(JSON.stringify(lt));
+ if (lt.type != "KEYW" || ["IF", 'WHILE'].indexOf(lt.name) < -1) {
if (!this.ignoreBadGrammer) {
throw {
name : "ArgumentError",
return true;
- },
+ }
/**
@returns {Boolean} Was the token found?