1
0

Implement LINPUT

This commit is contained in:
otya128
2016-12-29 17:59:47 +09:00
parent c0f1e4e9e5
commit 20889c28e1
5 changed files with 80 additions and 0 deletions

View File

@@ -82,6 +82,7 @@ class Lexical
reserved["REPEAT"] = TokenType.Repeat;
reserved["UNTIL"] = TokenType.Until;
reserved["SWAP"] = TokenType.Swap;
reserved["LINPUT"] = TokenType.Linput;
reserved.rehash();
}
this(wstring input)
@@ -1124,6 +1125,8 @@ class Parser
break;
case TokenType.Swap:
return swapStatement();
case TokenType.Linput:
return linputStatement();
default:
syntaxError();
break;
@@ -1131,6 +1134,38 @@ class Parser
lex.popFront();
return node;
}
Linput linputStatement()
{
auto location = lex.location;
lex.popFront();
Expression message = expression();
if(!message)
{
syntaxError();
return null;
}
auto token = lex.front();
if (token.type == TokenType.Semicolon)
{
lex.popFront();
Expression var = expression();
if (!isLValue(var))
{
syntaxError();
return null;
}
return new Linput(message, var, location);
}
else
{
if (!isLValue(message))
{
syntaxError();
return null;
}
return new Linput(message, location);
}
}
Swap swapStatement()
{
lex.popFront();