VMを定義,文の構文木のクラスを定義
This commit is contained in:
@@ -210,5 +210,6 @@
|
||||
<File path="parser.d" />
|
||||
<File path="token.d" />
|
||||
<File path="type.d" />
|
||||
<File path="VM.d" />
|
||||
</Folder>
|
||||
</DProject>
|
||||
|
||||
38
SMILEBASIC/VM.d
Normal file
38
SMILEBASIC/VM.d
Normal file
@@ -0,0 +1,38 @@
|
||||
module otya.smilebasic.VM;
|
||||
class VM
|
||||
{
|
||||
}
|
||||
enum CodeType
|
||||
{
|
||||
PushI,
|
||||
PushD,
|
||||
PushS,
|
||||
Operate,
|
||||
Return,
|
||||
Goto,
|
||||
Gosub,
|
||||
}
|
||||
abstract class Code
|
||||
{
|
||||
CodeType type;
|
||||
abstract void execute(VM vm);
|
||||
}
|
||||
/*
|
||||
* スタックにPush
|
||||
*/
|
||||
class Push : Code
|
||||
{
|
||||
|
||||
}
|
||||
class Operate : Code
|
||||
{
|
||||
|
||||
}
|
||||
class Goto : Code
|
||||
{
|
||||
|
||||
}
|
||||
class Gosub : Code
|
||||
{
|
||||
|
||||
}
|
||||
@@ -12,6 +12,12 @@ enum NodeType
|
||||
Variable,
|
||||
CallFunction,
|
||||
VoidExpression,
|
||||
|
||||
Statements,
|
||||
FunctionBody,
|
||||
Assign,
|
||||
CallFunctionStatement,
|
||||
Print,
|
||||
}
|
||||
abstract class Node
|
||||
{
|
||||
@@ -85,3 +91,44 @@ class VoidExpression : Expression
|
||||
this.type = NodeType.VoidExpression;
|
||||
}
|
||||
}
|
||||
abstract class Statement : Node
|
||||
{
|
||||
}
|
||||
class Statements : Statement
|
||||
{
|
||||
Statement[] statements;
|
||||
this()
|
||||
{
|
||||
this.type = NodeType.Statements;
|
||||
}
|
||||
void addStatement(Statement statement)
|
||||
{
|
||||
statements ~= statement;
|
||||
}
|
||||
}
|
||||
|
||||
enum PrintArgumentType
|
||||
{
|
||||
Expression,//exp
|
||||
LF,
|
||||
Tab,//,
|
||||
}
|
||||
/*
|
||||
*PRINTは関数ではないしmkIIと違って必ず:がいる
|
||||
*関数と違ってFUNC(,,,)のような記述はエラー
|
||||
*と言っても3.2で上の記述もエラーになりうる
|
||||
*/
|
||||
|
||||
class Print : Statement
|
||||
{
|
||||
/*
|
||||
*;は基本無視
|
||||
*/
|
||||
struct PrintArgument
|
||||
{
|
||||
PrintArgumentType type;
|
||||
Expression expression;
|
||||
}
|
||||
PrintArgument[] args;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user