mirror of https://github.com/adamdruppe/arsd.git
even more hacks
This commit is contained in:
parent
073e414520
commit
6710dd5f23
19
script.d
19
script.d
|
@ -1,6 +1,8 @@
|
||||||
/**
|
/**
|
||||||
Script features:
|
Script features:
|
||||||
|
|
||||||
|
FIXME: add COM support on Windows
|
||||||
|
|
||||||
OVERVIEW
|
OVERVIEW
|
||||||
* easy interop with D thanks to arsd.jsvar. When interpreting, pass a var object to use as globals.
|
* easy interop with D thanks to arsd.jsvar. When interpreting, pass a var object to use as globals.
|
||||||
This object also contains the global state when interpretation is done.
|
This object also contains the global state when interpretation is done.
|
||||||
|
@ -113,7 +115,7 @@
|
||||||
*/
|
*/
|
||||||
module arsd.script;
|
module arsd.script;
|
||||||
|
|
||||||
import arsd.jsvar;
|
public import arsd.jsvar;
|
||||||
|
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.traits;
|
import std.traits;
|
||||||
|
@ -230,9 +232,18 @@ class TokenStream(TextStream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() {
|
bool empty() {
|
||||||
|
advanceSkips();
|
||||||
return text.length == 0 && textStream.empty && !peeked;
|
return text.length == 0 && textStream.empty && !peeked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int skipNext;
|
||||||
|
void advanceSkips() {
|
||||||
|
if(skipNext) {
|
||||||
|
skipNext--;
|
||||||
|
popFront();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void popFront() {
|
void popFront() {
|
||||||
if(peeked) {
|
if(peeked) {
|
||||||
peeked = false;
|
peeked = false;
|
||||||
|
@ -1953,8 +1964,8 @@ Expression parseExpression(MyTokenStreamHere)(ref MyTokenStreamHere tokens, bool
|
||||||
|
|
||||||
//writeln("parsed expression ", ret.toString());
|
//writeln("parsed expression ", ret.toString());
|
||||||
|
|
||||||
if(tokens.empty)
|
if(expectedEnd.length && tokens.empty)
|
||||||
throw new ScriptCompileException("Parse error, unexpected end of input when reading expression", first.lineNumber);
|
throw new ScriptCompileException("Parse error, unexpected end of input when reading expression, expecting " ~ expectedEnd, first.lineNumber);
|
||||||
|
|
||||||
if(expectedEnd.length && consumeEnd) {
|
if(expectedEnd.length && consumeEnd) {
|
||||||
if(tokens.peekNextToken(ScriptToken.Type.symbol, expectedEnd))
|
if(tokens.peekNextToken(ScriptToken.Type.symbol, expectedEnd))
|
||||||
|
@ -2169,7 +2180,7 @@ struct CompoundStatementRange(MyTokenStreamHere) {
|
||||||
|
|
||||||
if(terminatingSymbol !is null) {
|
if(terminatingSymbol !is null) {
|
||||||
assert(tokens.front.str == terminatingSymbol);
|
assert(tokens.front.str == terminatingSymbol);
|
||||||
tokens.popFront();
|
tokens.skipNext++;
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmpty = true;
|
isEmpty = true;
|
||||||
|
|
Loading…
Reference in New Issue