Add XON/XOFF parsing support & Fix OPTION
This commit is contained in:
@@ -46,6 +46,8 @@ enum NodeType
|
|||||||
Swap,
|
Swap,
|
||||||
AssignRef,
|
AssignRef,
|
||||||
VarRef,
|
VarRef,
|
||||||
|
XOn,
|
||||||
|
XOff,
|
||||||
}
|
}
|
||||||
abstract class Node
|
abstract class Node
|
||||||
{
|
{
|
||||||
@@ -631,3 +633,24 @@ class VarRef : Expression
|
|||||||
this.expression = expr;
|
this.expression = expr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class XOn : Statement
|
||||||
|
{
|
||||||
|
wstring func;
|
||||||
|
this(wstring func, SourceLocation loc)
|
||||||
|
{
|
||||||
|
super.location = loc;
|
||||||
|
this.type = NodeType.XOn;
|
||||||
|
this.func = func;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class XOff : Statement
|
||||||
|
{
|
||||||
|
wstring func;
|
||||||
|
this(wstring func, SourceLocation loc)
|
||||||
|
{
|
||||||
|
super.location = loc;
|
||||||
|
this.type = NodeType.XOff;
|
||||||
|
this.func = func;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -864,8 +864,11 @@ class Parser
|
|||||||
case TokenType.Iden:
|
case TokenType.Iden:
|
||||||
{
|
{
|
||||||
wstring name = token.value.stringValue;
|
wstring name = token.value.stringValue;
|
||||||
if (name == "OPTION")
|
auto uname = std.uni.toUpper(name);
|
||||||
|
if (uname == "OPTION")
|
||||||
{
|
{
|
||||||
|
lex.popFront;
|
||||||
|
token = lex.front;
|
||||||
if (token.type != TokenType.Iden)
|
if (token.type != TokenType.Iden)
|
||||||
{
|
{
|
||||||
syntaxError();
|
syntaxError();
|
||||||
@@ -880,6 +883,24 @@ class Parser
|
|||||||
lex.popFront();
|
lex.popFront();
|
||||||
return new Option(arg, lex.location);
|
return new Option(arg, lex.location);
|
||||||
}
|
}
|
||||||
|
if (uname == "XON" || uname == "XOFF")
|
||||||
|
{
|
||||||
|
lex.popFront;
|
||||||
|
token = lex.front;
|
||||||
|
if (token.type != TokenType.Iden)
|
||||||
|
{
|
||||||
|
syntaxError();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
auto arg = std.uni.toUpper(token.value.stringValue);
|
||||||
|
if (arg != "MOTION" && arg != "EXPAD" && arg != "MIC" && arg != "WIIU")
|
||||||
|
{
|
||||||
|
syntaxError();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
lex.popFront();
|
||||||
|
return uname == "XON" ? new XOn(arg, lex.location) : new XOff(arg, lex.location);
|
||||||
|
}
|
||||||
if (token.type != TokenType.Call)
|
if (token.type != TokenType.Call)
|
||||||
{
|
{
|
||||||
auto old = lex.save;
|
auto old = lex.save;
|
||||||
|
|||||||
Reference in New Issue
Block a user