init
This commit is contained in:
22
SMILEBASIC.sln
Normal file
22
SMILEBASIC.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "SMILEBASIC", "SMILEBASIC\SMILEBASIC.visualdproj", "{02748C89-9CEB-48FE-B711-36F7A9951ED8}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{02748C89-9CEB-48FE-B711-36F7A9951ED8}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{02748C89-9CEB-48FE-B711-36F7A9951ED8}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{02748C89-9CEB-48FE-B711-36F7A9951ED8}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{02748C89-9CEB-48FE-B711-36F7A9951ED8}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
217
SMILEBASIC/SMILEBASIC.visualdproj
Normal file
217
SMILEBASIC/SMILEBASIC.visualdproj
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
<DProject>
|
||||||
|
<ProjectGuid>{02748C89-9CEB-48FE-B711-36F7A9951ED8}</ProjectGuid>
|
||||||
|
<Config name="Debug" platform="Win32">
|
||||||
|
<obj>0</obj>
|
||||||
|
<link>0</link>
|
||||||
|
<lib>0</lib>
|
||||||
|
<subsystem>0</subsystem>
|
||||||
|
<multiobj>0</multiobj>
|
||||||
|
<singleFileCompilation>0</singleFileCompilation>
|
||||||
|
<oneobj>0</oneobj>
|
||||||
|
<mscoff>0</mscoff>
|
||||||
|
<trace>0</trace>
|
||||||
|
<quiet>0</quiet>
|
||||||
|
<verbose>0</verbose>
|
||||||
|
<vtls>0</vtls>
|
||||||
|
<vgc>0</vgc>
|
||||||
|
<symdebug>1</symdebug>
|
||||||
|
<optimize>0</optimize>
|
||||||
|
<cpu>0</cpu>
|
||||||
|
<isX86_64>0</isX86_64>
|
||||||
|
<isLinux>0</isLinux>
|
||||||
|
<isOSX>0</isOSX>
|
||||||
|
<isWindows>0</isWindows>
|
||||||
|
<isFreeBSD>0</isFreeBSD>
|
||||||
|
<isSolaris>0</isSolaris>
|
||||||
|
<scheduler>0</scheduler>
|
||||||
|
<useDeprecated>0</useDeprecated>
|
||||||
|
<errDeprecated>0</errDeprecated>
|
||||||
|
<useAssert>0</useAssert>
|
||||||
|
<useInvariants>0</useInvariants>
|
||||||
|
<useIn>0</useIn>
|
||||||
|
<useOut>0</useOut>
|
||||||
|
<useArrayBounds>0</useArrayBounds>
|
||||||
|
<noboundscheck>0</noboundscheck>
|
||||||
|
<useSwitchError>0</useSwitchError>
|
||||||
|
<useUnitTests>0</useUnitTests>
|
||||||
|
<useInline>0</useInline>
|
||||||
|
<release>0</release>
|
||||||
|
<preservePaths>0</preservePaths>
|
||||||
|
<warnings>0</warnings>
|
||||||
|
<infowarnings>0</infowarnings>
|
||||||
|
<checkProperty>0</checkProperty>
|
||||||
|
<genStackFrame>0</genStackFrame>
|
||||||
|
<pic>0</pic>
|
||||||
|
<cov>0</cov>
|
||||||
|
<nofloat>0</nofloat>
|
||||||
|
<Dversion>2.043</Dversion>
|
||||||
|
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
|
||||||
|
<allinst>0</allinst>
|
||||||
|
<stackStomp>0</stackStomp>
|
||||||
|
<compiler>0</compiler>
|
||||||
|
<otherDMD>0</otherDMD>
|
||||||
|
<cccmd>$(CC) -c</cccmd>
|
||||||
|
<ccTransOpt>1</ccTransOpt>
|
||||||
|
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
|
||||||
|
<imppath />
|
||||||
|
<fileImppath />
|
||||||
|
<outdir>$(ConfigurationName)</outdir>
|
||||||
|
<objdir>$(OutDir)</objdir>
|
||||||
|
<objname />
|
||||||
|
<libname />
|
||||||
|
<doDocComments>0</doDocComments>
|
||||||
|
<docdir />
|
||||||
|
<docname />
|
||||||
|
<modules_ddoc />
|
||||||
|
<ddocfiles />
|
||||||
|
<doHdrGeneration>0</doHdrGeneration>
|
||||||
|
<hdrdir />
|
||||||
|
<hdrname />
|
||||||
|
<doXGeneration>1</doXGeneration>
|
||||||
|
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
||||||
|
<debuglevel>0</debuglevel>
|
||||||
|
<debugids />
|
||||||
|
<versionlevel>0</versionlevel>
|
||||||
|
<versionids />
|
||||||
|
<dump_source>0</dump_source>
|
||||||
|
<mapverbosity>0</mapverbosity>
|
||||||
|
<createImplib>0</createImplib>
|
||||||
|
<defaultlibname />
|
||||||
|
<debuglibname />
|
||||||
|
<moduleDepsFile />
|
||||||
|
<run>0</run>
|
||||||
|
<runargs />
|
||||||
|
<runCv2pdb>1</runCv2pdb>
|
||||||
|
<pathCv2pdb>$(VisualDInstallDir)cv2pdb\cv2pdb.exe</pathCv2pdb>
|
||||||
|
<cv2pdbPre2043>0</cv2pdbPre2043>
|
||||||
|
<cv2pdbNoDemangle>0</cv2pdbNoDemangle>
|
||||||
|
<cv2pdbEnumType>0</cv2pdbEnumType>
|
||||||
|
<cv2pdbOptions />
|
||||||
|
<objfiles />
|
||||||
|
<linkswitches />
|
||||||
|
<libfiles />
|
||||||
|
<libpaths />
|
||||||
|
<deffile />
|
||||||
|
<resfile />
|
||||||
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
|
<useStdLibPath>1</useStdLibPath>
|
||||||
|
<cRuntime>2</cRuntime>
|
||||||
|
<privatePhobos>0</privatePhobos>
|
||||||
|
<additionalOptions />
|
||||||
|
<preBuildCommand />
|
||||||
|
<postBuildCommand />
|
||||||
|
<filesToClean>*.obj;*.cmd;*.build;*.json;*.dep</filesToClean>
|
||||||
|
</Config>
|
||||||
|
<Config name="Release" platform="Win32">
|
||||||
|
<obj>0</obj>
|
||||||
|
<link>0</link>
|
||||||
|
<lib>0</lib>
|
||||||
|
<subsystem>0</subsystem>
|
||||||
|
<multiobj>0</multiobj>
|
||||||
|
<singleFileCompilation>0</singleFileCompilation>
|
||||||
|
<oneobj>0</oneobj>
|
||||||
|
<mscoff>0</mscoff>
|
||||||
|
<trace>0</trace>
|
||||||
|
<quiet>0</quiet>
|
||||||
|
<verbose>0</verbose>
|
||||||
|
<vtls>0</vtls>
|
||||||
|
<vgc>0</vgc>
|
||||||
|
<symdebug>0</symdebug>
|
||||||
|
<optimize>0</optimize>
|
||||||
|
<cpu>0</cpu>
|
||||||
|
<isX86_64>0</isX86_64>
|
||||||
|
<isLinux>0</isLinux>
|
||||||
|
<isOSX>0</isOSX>
|
||||||
|
<isWindows>0</isWindows>
|
||||||
|
<isFreeBSD>0</isFreeBSD>
|
||||||
|
<isSolaris>0</isSolaris>
|
||||||
|
<scheduler>0</scheduler>
|
||||||
|
<useDeprecated>0</useDeprecated>
|
||||||
|
<errDeprecated>0</errDeprecated>
|
||||||
|
<useAssert>0</useAssert>
|
||||||
|
<useInvariants>0</useInvariants>
|
||||||
|
<useIn>0</useIn>
|
||||||
|
<useOut>0</useOut>
|
||||||
|
<useArrayBounds>0</useArrayBounds>
|
||||||
|
<noboundscheck>0</noboundscheck>
|
||||||
|
<useSwitchError>0</useSwitchError>
|
||||||
|
<useUnitTests>0</useUnitTests>
|
||||||
|
<useInline>0</useInline>
|
||||||
|
<release>1</release>
|
||||||
|
<preservePaths>0</preservePaths>
|
||||||
|
<warnings>0</warnings>
|
||||||
|
<infowarnings>0</infowarnings>
|
||||||
|
<checkProperty>0</checkProperty>
|
||||||
|
<genStackFrame>0</genStackFrame>
|
||||||
|
<pic>0</pic>
|
||||||
|
<cov>0</cov>
|
||||||
|
<nofloat>0</nofloat>
|
||||||
|
<Dversion>2.043</Dversion>
|
||||||
|
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
|
||||||
|
<allinst>0</allinst>
|
||||||
|
<stackStomp>0</stackStomp>
|
||||||
|
<compiler>0</compiler>
|
||||||
|
<otherDMD>0</otherDMD>
|
||||||
|
<cccmd>$(CC) -c</cccmd>
|
||||||
|
<ccTransOpt>1</ccTransOpt>
|
||||||
|
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
|
||||||
|
<imppath />
|
||||||
|
<fileImppath />
|
||||||
|
<outdir>$(ConfigurationName)</outdir>
|
||||||
|
<objdir>$(OutDir)</objdir>
|
||||||
|
<objname />
|
||||||
|
<libname />
|
||||||
|
<doDocComments>0</doDocComments>
|
||||||
|
<docdir />
|
||||||
|
<docname />
|
||||||
|
<modules_ddoc />
|
||||||
|
<ddocfiles />
|
||||||
|
<doHdrGeneration>0</doHdrGeneration>
|
||||||
|
<hdrdir />
|
||||||
|
<hdrname />
|
||||||
|
<doXGeneration>1</doXGeneration>
|
||||||
|
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
||||||
|
<debuglevel>0</debuglevel>
|
||||||
|
<debugids />
|
||||||
|
<versionlevel>0</versionlevel>
|
||||||
|
<versionids />
|
||||||
|
<dump_source>0</dump_source>
|
||||||
|
<mapverbosity>0</mapverbosity>
|
||||||
|
<createImplib>0</createImplib>
|
||||||
|
<defaultlibname />
|
||||||
|
<debuglibname />
|
||||||
|
<moduleDepsFile />
|
||||||
|
<run>0</run>
|
||||||
|
<runargs />
|
||||||
|
<runCv2pdb>0</runCv2pdb>
|
||||||
|
<pathCv2pdb>$(VisualDInstallDir)cv2pdb\cv2pdb.exe</pathCv2pdb>
|
||||||
|
<cv2pdbPre2043>0</cv2pdbPre2043>
|
||||||
|
<cv2pdbNoDemangle>0</cv2pdbNoDemangle>
|
||||||
|
<cv2pdbEnumType>0</cv2pdbEnumType>
|
||||||
|
<cv2pdbOptions />
|
||||||
|
<objfiles />
|
||||||
|
<linkswitches />
|
||||||
|
<libfiles />
|
||||||
|
<libpaths />
|
||||||
|
<deffile />
|
||||||
|
<resfile />
|
||||||
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
|
<useStdLibPath>1</useStdLibPath>
|
||||||
|
<cRuntime>1</cRuntime>
|
||||||
|
<privatePhobos>0</privatePhobos>
|
||||||
|
<additionalOptions />
|
||||||
|
<preBuildCommand />
|
||||||
|
<postBuildCommand />
|
||||||
|
<filesToClean>*.obj;*.cmd;*.build;*.json;*.dep</filesToClean>
|
||||||
|
</Config>
|
||||||
|
<Folder name="SMILEBASIC">
|
||||||
|
<Folder name="otya">
|
||||||
|
<Folder name="smilebasic" />
|
||||||
|
<File path="node.d" />
|
||||||
|
<File path="parser.d" />
|
||||||
|
<File path="token.d" />
|
||||||
|
<File path="type.d" />
|
||||||
|
</Folder>
|
||||||
|
<File path="main.d" />
|
||||||
|
</Folder>
|
||||||
|
</DProject>
|
||||||
6
SMILEBASIC/main.d
Normal file
6
SMILEBASIC/main.d
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import std.stdio;
|
||||||
|
int main(string[] argv)
|
||||||
|
{
|
||||||
|
writeln("Hello D-World!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
38
SMILEBASIC/node.d
Normal file
38
SMILEBASIC/node.d
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
module otya.smilebasic.node;
|
||||||
|
import otya.smilebasic.type;
|
||||||
|
import otya.smilebasic.token;
|
||||||
|
enum NodeType
|
||||||
|
{
|
||||||
|
Node = 0b1,
|
||||||
|
Expression,
|
||||||
|
Constant,
|
||||||
|
BinaryOperator,
|
||||||
|
}
|
||||||
|
abstract class Node
|
||||||
|
{
|
||||||
|
NodeType type;
|
||||||
|
}
|
||||||
|
abstract class Expression : Node
|
||||||
|
{
|
||||||
|
}
|
||||||
|
class Constant : Expression
|
||||||
|
{
|
||||||
|
Value value;
|
||||||
|
this(Value v)
|
||||||
|
{
|
||||||
|
this.value = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class BinaryOperator : Expression
|
||||||
|
{
|
||||||
|
Expression item1;
|
||||||
|
TokenType operator;
|
||||||
|
Expression item2;
|
||||||
|
this(Expression i1, TokenType o, Expression i2)
|
||||||
|
{
|
||||||
|
this.type = NodeType.BinaryOperator;
|
||||||
|
this.item1 = i1;
|
||||||
|
this.operator = o;
|
||||||
|
this.item2 = i2;
|
||||||
|
}
|
||||||
|
}
|
||||||
99
SMILEBASIC/parser.d
Normal file
99
SMILEBASIC/parser.d
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
module otya.smilebasic.parser;
|
||||||
|
import otya.smilebasic.token;
|
||||||
|
import otya.smilebasic.type;
|
||||||
|
import otya.smilebasic.node;
|
||||||
|
import std.ascii;
|
||||||
|
class Lexical
|
||||||
|
{
|
||||||
|
wstring code;
|
||||||
|
int index;
|
||||||
|
this(wstring input)
|
||||||
|
{
|
||||||
|
this.code = input;
|
||||||
|
}
|
||||||
|
bool empty()
|
||||||
|
{
|
||||||
|
return index >= code.length;
|
||||||
|
}
|
||||||
|
Token token;
|
||||||
|
void popFront()
|
||||||
|
{
|
||||||
|
int i = index;
|
||||||
|
for(;i < code.length;i++)
|
||||||
|
{
|
||||||
|
wchar c = code[i];
|
||||||
|
if(c == ' ') continue;
|
||||||
|
if(c.isDigit())
|
||||||
|
{
|
||||||
|
int num;
|
||||||
|
for(;i < code.length;i++)
|
||||||
|
{
|
||||||
|
c = code[i];
|
||||||
|
if(!c.isDigit())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
num = num * 10 + (c - '0');
|
||||||
|
}
|
||||||
|
token = Token(TokenType.Integer, Value(num));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//error
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index = i;
|
||||||
|
}
|
||||||
|
Token front()
|
||||||
|
{
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
auto lex = new Lexical("1");
|
||||||
|
|
||||||
|
}
|
||||||
|
class Parser
|
||||||
|
{
|
||||||
|
wstring code;
|
||||||
|
Lexical lex;
|
||||||
|
this(wstring input)
|
||||||
|
{
|
||||||
|
this.code = input;
|
||||||
|
lex = new Lexical(input);
|
||||||
|
}
|
||||||
|
int getOPRank(TokenType type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
// return 8;//&&,||
|
||||||
|
case TokenType.And:
|
||||||
|
case TokenType.Or:
|
||||||
|
case TokenType.Xor:
|
||||||
|
return 7;//AND,OR,XOR
|
||||||
|
|
||||||
|
// return 6;//==,!=,<,<=,>,>=
|
||||||
|
|
||||||
|
// return 5;//<<,>>
|
||||||
|
case TokenType.Plus:
|
||||||
|
case TokenType.Minus:
|
||||||
|
return 4;//+,-(bin)
|
||||||
|
case TokenType.Mul:
|
||||||
|
case TokenType.Div:
|
||||||
|
// return 3;//*,/,DIV,MOD
|
||||||
|
// return 2;//-,NOT,!
|
||||||
|
// return 1;//()
|
||||||
|
default:
|
||||||
|
return 0;//TODO:エラーにすべきかは実装次第
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void expression(Expression node)
|
||||||
|
{
|
||||||
|
term(8, node);
|
||||||
|
}
|
||||||
|
void term(int order, Expression node)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
30
SMILEBASIC/token.d
Normal file
30
SMILEBASIC/token.d
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
module otya.smilebasic.token;
|
||||||
|
import otya.smilebasic.type;
|
||||||
|
enum TokenType
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
Integer,
|
||||||
|
Double,
|
||||||
|
String,
|
||||||
|
Plus,
|
||||||
|
Minus,
|
||||||
|
Mul,
|
||||||
|
Div,
|
||||||
|
Mod,
|
||||||
|
Or,
|
||||||
|
And,
|
||||||
|
Xor,
|
||||||
|
Print,
|
||||||
|
If,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Token
|
||||||
|
{
|
||||||
|
TokenType type;
|
||||||
|
Value value;
|
||||||
|
this(TokenType t, Value v)
|
||||||
|
{
|
||||||
|
type = t;
|
||||||
|
value = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
37
SMILEBASIC/type.d
Normal file
37
SMILEBASIC/type.d
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
module otya.smilebasic.type;
|
||||||
|
enum ValueType : byte
|
||||||
|
{
|
||||||
|
Integer,
|
||||||
|
Double,
|
||||||
|
String,
|
||||||
|
Array,
|
||||||
|
IntegerArray,
|
||||||
|
DoubleArray,
|
||||||
|
StringArray,
|
||||||
|
}
|
||||||
|
struct Value
|
||||||
|
{
|
||||||
|
ValueType type;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
int integerValue;
|
||||||
|
double doubleValue;
|
||||||
|
wstring stringValue;
|
||||||
|
int[] intArray;
|
||||||
|
}
|
||||||
|
this(int value)
|
||||||
|
{
|
||||||
|
this.type = ValueType.Integer;
|
||||||
|
integerValue = value;
|
||||||
|
}
|
||||||
|
this(double value)
|
||||||
|
{
|
||||||
|
this.type = ValueType.Double;
|
||||||
|
doubleValue = value;
|
||||||
|
}
|
||||||
|
this(wstring value)
|
||||||
|
{
|
||||||
|
this.type = ValueType.String;
|
||||||
|
stringValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user