Compiler for lua 5.2 fixes.
This commit is contained in:
@@ -553,7 +553,6 @@ public class LexState {
|
|||||||
int llex(SemInfo seminfo) {
|
int llex(SemInfo seminfo) {
|
||||||
nbuff = 0;
|
nbuff = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
System.out.println("llex current " + ((int) current) + "("+((char)current)+")");
|
|
||||||
switch (current) {
|
switch (current) {
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r': {
|
case '\r': {
|
||||||
@@ -700,6 +699,7 @@ public class LexState {
|
|||||||
lookahead.token = TK_EOS; /* and discharge it */
|
lookahead.token = TK_EOS; /* and discharge it */
|
||||||
} else
|
} else
|
||||||
t.token = llex(t.seminfo); /* read next token */
|
t.token = llex(t.seminfo); /* read next token */
|
||||||
|
System.out.println("----- next t.token " + t.token + " (" + (t.token!=0? txtToken(t.token): "-")+") "+ linenumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
void lookahead() {
|
void lookahead() {
|
||||||
@@ -1974,12 +1974,14 @@ public class LexState {
|
|||||||
/* stat -> func | assignment */
|
/* stat -> func | assignment */
|
||||||
FuncState fs = this.fs;
|
FuncState fs = this.fs;
|
||||||
LHS_assign v = new LHS_assign();
|
LHS_assign v = new LHS_assign();
|
||||||
this.primaryexp(v.v);
|
this.suffixedexp(v.v);
|
||||||
if (v.v.k == VCALL) /* stat -> func */
|
if (t.token == '=' || t.token == ',') { /* stat -> assignment ? */
|
||||||
LuaC.SETARG_C(fs.getcodePtr(v.v), 1); /* call statement uses no results */
|
|
||||||
else { /* stat -> assignment */
|
|
||||||
v.prev = null;
|
v.prev = null;
|
||||||
this.assignment(v, 1);
|
assignment(v, 1);
|
||||||
|
}
|
||||||
|
else { /* stat -> func */
|
||||||
|
check_condition(v.v.k == VCALL, "syntax error");
|
||||||
|
LuaC.SETARG_C(fs.getcodePtr(v.v), 1); /* call statement uses no results */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2014,35 +2016,38 @@ public class LexState {
|
|||||||
fs.ret(first, nret);
|
fs.ret(first, nret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void statement() {
|
||||||
boolean statement() {
|
|
||||||
int line = this.linenumber; /* may be needed for error messages */
|
int line = this.linenumber; /* may be needed for error messages */
|
||||||
switch (this.t.token) {
|
switch (this.t.token) {
|
||||||
|
case ';': { /* stat -> ';' (empty statement) */
|
||||||
|
next(); /* skip ';' */
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TK_IF: { /* stat -> ifstat */
|
case TK_IF: { /* stat -> ifstat */
|
||||||
this.ifstat(line);
|
this.ifstat(line);
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
case TK_WHILE: { /* stat -> whilestat */
|
case TK_WHILE: { /* stat -> whilestat */
|
||||||
this.whilestat(line);
|
this.whilestat(line);
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
case TK_DO: { /* stat -> DO block END */
|
case TK_DO: { /* stat -> DO block END */
|
||||||
this.next(); /* skip DO */
|
this.next(); /* skip DO */
|
||||||
this.block();
|
this.block();
|
||||||
this.check_match(TK_END, TK_DO, line);
|
this.check_match(TK_END, TK_DO, line);
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
case TK_FOR: { /* stat -> forstat */
|
case TK_FOR: { /* stat -> forstat */
|
||||||
this.forstat(line);
|
this.forstat(line);
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
case TK_REPEAT: { /* stat -> repeatstat */
|
case TK_REPEAT: { /* stat -> repeatstat */
|
||||||
this.repeatstat(line);
|
this.repeatstat(line);
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
case TK_FUNCTION: {
|
case TK_FUNCTION: {
|
||||||
this.funcstat(line); /* stat -> funcstat */
|
this.funcstat(line); /* stat -> funcstat */
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
case TK_LOCAL: { /* stat -> localstat */
|
case TK_LOCAL: { /* stat -> localstat */
|
||||||
this.next(); /* skip LOCAL */
|
this.next(); /* skip LOCAL */
|
||||||
@@ -2050,23 +2055,32 @@ public class LexState {
|
|||||||
this.localfunc();
|
this.localfunc();
|
||||||
else
|
else
|
||||||
this.localstat();
|
this.localstat();
|
||||||
return false;
|
break;
|
||||||
|
}
|
||||||
|
case TK_DBCOLON: { /* stat -> label */
|
||||||
|
next(); /* skip double colon */
|
||||||
|
labelstat(str_checkname(), line);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TK_RETURN: { /* stat -> retstat */
|
case TK_RETURN: { /* stat -> retstat */
|
||||||
|
next(); /* skip RETURN */
|
||||||
this.retstat();
|
this.retstat();
|
||||||
return true; /* must be last statement */
|
break;
|
||||||
}
|
}
|
||||||
case TK_BREAK:
|
case TK_BREAK:
|
||||||
case TK_GOTO: { /* stat -> breakstat */
|
case TK_GOTO: { /* stat -> breakstat */
|
||||||
this.next(); /* skip BREAK */
|
|
||||||
this.gotostat(fs.jump());
|
this.gotostat(fs.jump());
|
||||||
return true; /* must be last statement */
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
this.exprstat();
|
this.exprstat();
|
||||||
return false; /* to avoid warnings */
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LuaC._assert(fs.f.maxstacksize >= fs.freereg
|
||||||
|
&& fs.freereg >= fs.nactvar);
|
||||||
|
fs.freereg = fs.nactvar; /* free registers */
|
||||||
|
leavelevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void statlist() {
|
void statlist() {
|
||||||
|
|||||||
Reference in New Issue
Block a user