Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
95fa888
change symbol to A_ty
firtial May 29, 2018
fa1e1d2
change symbol to A_ty
firtial May 29, 2018
bd7837d
change symbol to ty for array
firtial May 30, 2018
18e1449
absyn
feiba15 May 30, 2018
cfa801e
Revert "absyn"
feiba15 May 30, 2018
6eaea6a
semant修改
feiba15 May 30, 2018
36846b0
可以生成exe
feiba15 May 31, 2018
63c14f1
update for vs
firtial May 31, 2018
553e69a
update for vs
firtial May 31, 2018
217cf5c
adjust for vs 0.1
firtial May 31, 2018
061b5b3
add findescape
firtial May 31, 2018
f4670e3
semant.c修改完成
feiba15 Jun 1, 2018
7aa7d76
修改工程文件
feiba15 Jun 1, 2018
f2c8f9a
Merge branch 'test' of github.com:ZhaoXiangyuMe/PascalCompiler into test
firtial Jun 1, 2018
288fcf4
fix debug error of temp l76
firtial Jun 1, 2018
ad2000f
add to print IR tree:
firtial Jun 1, 2018
a666070
fix seq bug
firtial Jun 1, 2018
6d5c2b9
fix frame bug
firtial Jun 1, 2018
b67b821
fix some frame bugs about alloc
firtial Jun 1, 2018
8e07605
修补const赋值
feiba15 Jun 2, 2018
9a1ca1c
fix array type
firtial Jun 2, 2018
39e2d19
merge for readme
firtial Jun 2, 2018
4993553
semant bug修补完成
feiba15 Jun 2, 2018
22bde10
semant bug修改
feiba15 Jun 2, 2018
279a5af
semant bug修改
feiba15 Jun 2, 2018
c1faf70
test for, while, repeat
firtial Jun 2, 2018
8fd7312
merger for array
firtial Jun 2, 2018
c7eb388
try merge
firtial Jun 2, 2018
6871f85
array assign fix 0.0
firtial Jun 2, 2018
006e6b7
more test on 3.pas
firtial Jun 2, 2018
14350dc
修补semant bug
feiba15 Jun 2, 2018
7b701d4
Merge remote-tracking branch 'refs/remotes/origin/test' into test
feiba15 Jun 2, 2018
c06dd93
recover
firtial Jun 2, 2018
73777ec
Merge branch 'test' of github.com:ZhaoXiangyuMe/PascalCompiler into test
firtial Jun 2, 2018
864f0d0
add size parameter to allocaLocal
firtial Jun 3, 2018
21359ac
修补bug
feiba15 Jun 3, 2018
009ed03
接口修改
feiba15 Jun 3, 2018
e101677
接口修改
feiba15 Jun 3, 2018
f9e3151
fix translate recordExp
firtial Jun 3, 2018
d68677a
add ignore
firtial Jun 3, 2018
99b2616
update gitignore
firtial Jun 3, 2018
1845c5f
add function and procedure
firtial Jun 3, 2018
d630491
add escape
firtial Jun 4, 2018
410da73
添加mod和div
feiba15 Jun 4, 2018
ecbd23e
Merge branch 'test' of github.com:ZhaoXiangyuMe/PascalCompiler into test
firtial Jun 4, 2018
cce654d
fix more on error recovering
firtial Jun 4, 2018
4af97e0
add IRTree-graph support
firtial Jun 5, 2018
4e9687b
添加注释
feiba15 Jun 5, 2018
b10ee0d
Merge branch 'test' of github.com:ZhaoXiangyuMe/PascalCompiler into test
firtial Jun 5, 2018
a347b4c
变量重定义
feiba15 Jun 6, 2018
86207d7
更新
feiba15 Jun 6, 2018
c13241e
test for comment
firtial Jun 6, 2018
faab6f1
修改注释
feiba15 Jun 6, 2018
51594a9
change y for something
firtial Jun 6, 2018
8b859f9
Merge branch 'test' of github.com:ZhaoXiangyuMe/PascalCompiler into test
firtial Jun 6, 2018
0cb798f
注释修改
feiba15 Jun 8, 2018
b4771b2
update gitignore
firtial Jun 8, 2018
b4850e5
.container {
firtial Jun 8, 2018
4d3e02d
Merge branch 'test' of github.com:ZhaoXiangyuMe/PascalCompiler into test
firtial Jun 8, 2018
17cb196
fix char and string
firtial Jun 8, 2018
83c9a63
注释修改
feiba15 Jun 9, 2018
441e321
修改大小写和函数返回值
feiba15 Jun 9, 2018
efbc926
刷新
feiba15 Jun 9, 2018
d1f705d
add test
firtial Jun 10, 2018
da53f5d
another
firtial Jun 10, 2018
1960586
修改多重定义
feiba15 Jun 10, 2018
758a33d
打印符号表并修补变量定义bug
feiba15 Jun 10, 2018
3f5f31e
Merge branch 'test' of github.com:ZhaoXiangyuMe/PascalCompiler into test
firtial Jun 10, 2018
3822096
update for codegen
firtial Jun 16, 2018
854faf9
ange readme
firtial Jun 16, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

#cyg
*.stackdump

# vs
*.suo
*.VC.db
*.filters
*.user
*/Debug/
*/x64/
Debug/
*VC.opendb

# graphdot
*.dot
*.jpg
Binary file added .vs/CompilerPascal/v14/.suo
Binary file not shown.
Binary file added CompilerPascal.VC.db
Binary file not shown.
28 changes: 28 additions & 0 deletions CompilerPascal.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CompilerPascal", "CompilerPascal\CompilerPascal.vcxproj", "{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}.Debug|x64.ActiveCfg = Debug|x64
{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}.Debug|x64.Build.0 = Debug|x64
{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}.Debug|x86.ActiveCfg = Debug|Win32
{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}.Debug|x86.Build.0 = Debug|Win32
{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}.Release|x64.ActiveCfg = Release|x64
{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}.Release|x64.Build.0 = Release|x64
{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}.Release|x86.ActiveCfg = Release|Win32
{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
7 changes: 7 additions & 0 deletions CompilerPascal/1pas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
y VAR INT
x VAR INT
max FUN INT INT INT
rec VAR RECORD
s VAR STRING
outer VAR INT
c VAR CHAR
3 changes: 3 additions & 0 deletions CompilerPascal/2pas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
x NAME
y VAR INT
x VAR INT
19 changes: 19 additions & 0 deletions CompilerPascal/3pas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
mc VAR CHAR
x VAR INT
linktest FUN INT CHAR
m VAR CHAR
t VAR INT
y VAR INT
x VAR INT
y VAR INT
x VAR INT
max FUN INT INT INT
swap FUN INT INT VOID
a VAR ARRAY
sum VAR INT
i VAR INT
y VAR INT
x VAR INT
n VAR REAL
m VAR REAL
c VAR CHAR
14 changes: 14 additions & 0 deletions CompilerPascal/4pas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
y VAR INT
x VAR INT
max FUN INT INT INT
ar VAR ARRAY
rec VAR RECORD
k VAR BOOLEAN
outer VAR INT
z VAR CHAR
i VAR INT
y VAR INT
x VAR INT
c CONST REAL
b CONST INT
a CONST INT
4 changes: 4 additions & 0 deletions CompilerPascal/5pas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rec VAR RECORD
s VAR STRING
outer VAR INT
c VAR CHAR
161 changes: 161 additions & 0 deletions CompilerPascal/CompilerPascal.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{30F849DD-F677-4B3D-B1F2-59B1C74F8D8D}</ProjectGuid>
<RootNamespace>CompilerPascal</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="absyn.h" />
<ClInclude Include="assem.h" />
<ClInclude Include="canon.h" />
<ClInclude Include="codegen.h" />
<ClInclude Include="drawtree.h" />
<ClInclude Include="env.h" />
<ClInclude Include="errormsg.h" />
<ClInclude Include="escape.h" />
<ClInclude Include="frame.h" />
<ClInclude Include="prabsyn.h" />
<ClInclude Include="printtree.h" />
<ClInclude Include="semant.h" />
<ClInclude Include="symbol.h" />
<ClInclude Include="table.h" />
<ClInclude Include="temp.h" />
<ClInclude Include="translate.h" />
<ClInclude Include="tree.h" />
<ClInclude Include="types.h" />
<ClInclude Include="util.h" />
<ClInclude Include="y.tab.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="absyn.c" />
<ClCompile Include="assem.c" />
<ClCompile Include="canon.c" />
<ClCompile Include="codegen.c" />
<ClCompile Include="drawtree.c" />
<ClCompile Include="env.c" />
<ClCompile Include="errormsg.c" />
<ClCompile Include="escape.c" />
<ClCompile Include="lex.yy.c" />
<ClCompile Include="main.c" />
<ClCompile Include="mipsframe.c" />
<ClCompile Include="prabsyn.c" />
<ClCompile Include="printtree.c" />
<ClCompile Include="semant.c" />
<ClCompile Include="symbol.c" />
<ClCompile Include="table.c" />
<ClCompile Include="temp.c" />
<ClCompile Include="translate.c" />
<ClCompile Include="tree.c" />
<ClCompile Include="types.c" />
<ClCompile Include="util.c" />
<ClCompile Include="y.tab.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
33 changes: 33 additions & 0 deletions CompilerPascal/IRTree.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
digraph g {
node[peripheries=2, style=filled;]
node1->node2;
node1[label="LABEL"];
node2[label="L12"];
node3->node4->node5;
node4[label="TEMP"];
node5[label="t100"];
node3->node6->node7;
node6[label="CONST"];
node7[label="0"];
node3[label="MOVE"];
node8->node9->node10;
node9[label="TEMP"];
node10[label="t100"];
node8->node11->node12;
node11->node13->node14;
node13[label="TEMP"];
node14[label="t100"];
node11->node15->node16;
node15[label="CONST"];
node16[label="1"];
node11[label="BINOP"];
node12[label="PLUS"];
node8[label="MOVE"];
node17->node18->node19;
node18[label="NAME"];
node19[label="L11"];
node17[label="JUMP"];
node20->node21;
node20[label="LABEL"];
node21[label="L11"];
}
25 changes: 23 additions & 2 deletions src/Makefile → CompilerPascal/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
objects = main.o semant.o env.o types.o translate.o tree.o prabsyn.o temp.o frame.o symbol.o table.o absyn.o util.o errormsg.o y.tab.o lex.yy.o
objects = main.o codegen.o assem.o canon.o drawtree.o printtree.o semant.o env.o types.o escape.o translate.o tree.o prabsyn.o temp.o frame.o symbol.o table.o absyn.o util.o errormsg.o y.tab.o lex.yy.o
pascalc: $(objects)
cc -o pascalc -g $(objects)


main.o:
cc -g -c main.c

codegen.o: codegen.c codegen.h
cc -g -c codegen.c

assem.o: assem.c assem.h
cc -g -c assem.c

canon.o: canon.c canon.h
cc -g -c canon.c

drawtree.o: drawtree.c drawtree.h
cc -g -c drawtree.c

printtree.o: printtree.c printtree.h
cc -g -c printtree.c

semant.o: semant.c semant.h
cc -g -c semant.c

Expand All @@ -15,6 +30,9 @@ env.o: env.c env.h
types.o: types.c types.h
cc -g -c types.c

escape.o: escape.c escape.h
cc -g -c escape.c

translate.o: translate.c translate.h
cc -g -c translate.c

Expand Down Expand Up @@ -57,4 +75,7 @@ prabsyn.o: prabsyn.c prabsyn.h
cc -g -c prabsyn.c

clean:
rm -f *.o
rm -f *.o

graph:
dot -Tjpg IRTree.dot -o IRTree.jpg
Loading