update readme.me
This commit is contained in:
+1
-1
@@ -85,4 +85,4 @@ Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
|
||||
a.out
|
||||
|
||||
@@ -1119,7 +1119,7 @@ void PARSE() {
|
||||
while (I < instructions.size())
|
||||
{
|
||||
|
||||
cout << "\n inst "<< I << '\n';
|
||||
// cout << "\n inst "<< I << '\n';
|
||||
switch (instructions[I] ->nop)
|
||||
{
|
||||
case INT:
|
||||
@@ -23,7 +23,7 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>ConsoleApplication18</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>BadassPascal</ProjectName>
|
||||
<ProjectName>AwesomePascal</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@@ -157,7 +157,7 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="BadassPascal.cpp" />
|
||||
<ClCompile Include="AwesomePascal.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BadassPascal", "BadassPascal\BadassPascal.vcxproj", "{62CCFC20-46DF-4039-97A5-AA068BD6A016}"
|
||||
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
|
||||
{62CCFC20-46DF-4039-97A5-AA068BD6A016}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{62CCFC20-46DF-4039-97A5-AA068BD6A016}.Debug|x64.Build.0 = Debug|x64
|
||||
{62CCFC20-46DF-4039-97A5-AA068BD6A016}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{62CCFC20-46DF-4039-97A5-AA068BD6A016}.Debug|x86.Build.0 = Debug|Win32
|
||||
{62CCFC20-46DF-4039-97A5-AA068BD6A016}.Release|x64.ActiveCfg = Release|x64
|
||||
{62CCFC20-46DF-4039-97A5-AA068BD6A016}.Release|x64.Build.0 = Release|x64
|
||||
{62CCFC20-46DF-4039-97A5-AA068BD6A016}.Release|x86.ActiveCfg = Release|Win32
|
||||
{62CCFC20-46DF-4039-97A5-AA068BD6A016}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -48,8 +48,6 @@
|
||||
j:=f;
|
||||
i:=t;
|
||||
call q;
|
||||
write(a);
|
||||
write(b);
|
||||
begi:=begi+1;
|
||||
end;
|
||||
write(b);
|
||||
@@ -1,27 +1,25 @@
|
||||
const a=10;
|
||||
var b,c;
|
||||
var b,c,e;
|
||||
procedure p;
|
||||
var d;
|
||||
begin
|
||||
d:=20;
|
||||
write(d);
|
||||
c:=d/a;
|
||||
write(c);
|
||||
c:=c+b;
|
||||
write(c);
|
||||
if a<c then c:=c*2;
|
||||
write(c);
|
||||
end;
|
||||
|
||||
begin
|
||||
read (b);
|
||||
while b#0 do
|
||||
begin
|
||||
e := b;
|
||||
e := 4*e/2/3+(3*1);
|
||||
call p;
|
||||
write(c);
|
||||
write(e);
|
||||
read(b);
|
||||
b := 4*b/2/3+(3*1);
|
||||
write(b);
|
||||
end;
|
||||
b:=1;
|
||||
b:=999999999;
|
||||
write(b);
|
||||
end.
|
||||
@@ -1,12 +1,31 @@
|
||||
# BadassPascal
|
||||
### This code came from my undergrad course project for compiler principles in 2015, although I did minimum bug fixes on this recently, this code still can not be considered as efficient nor even readible by any means because a lot of hacks were used to make it work and the writing doesn't confrom to a stable coding style either. However, it is something that I was proud of at that time.
|
||||
# AwesomePascal
|
||||
|
||||
Another PL/0 language (https://en.wikipedia.org/wiki/PL/0) compiler and debugger written in C++.
|
||||
Another PL/0 language (https://en.wikipedia.org/wiki/PL/0) compiler and debugger that is written in C++.
|
||||
|
||||
## Introduction
|
||||
|
||||
This code came from my undergrad course project for compiler principles in 2015. The code quality is beyond horrible but it's some of my earliest big projects.
|
||||
|
||||
## Architecture
|
||||
- The compiler uses **SLR(1)** parsing. The grammar is hard-coded in the form of an LR parsing table (`states`) and the FOLLOW set (`follows`) which is initialized in `initStates()` function.
|
||||
- The compiler was written from the ground up **without any third-party libraries** except the standard C++ library.
|
||||
- It contains:
|
||||
- A lexer (`GETSYM()` function) that processes the input into tokens and literals while constructing a symbol table
|
||||
- A parser (`BLOCK()` function) that uses shift/reduce-parsing to generate the target code (pseudo-assembly)
|
||||
- An interpreter (`INTERPRET()` function) that executes the pseudo-assembly code.
|
||||
|
||||
## Build
|
||||
|
||||
Supported Environments:
|
||||
MSVC project: BadassPascal.sln
|
||||
GNU C++/Clang: compile BadassPascal.cpp directly
|
||||
>e.g.
|
||||
>`$ g++ -O3 BadassPascal.cpp -o BP`
|
||||
- MSVC project: AwesomePascal.vcxproj
|
||||
- GNU C++/Clang: compile AwesomePascal.cpp directly
|
||||
|
||||
## Examples
|
||||
- InsertionSort.pas: A simple program that takes 5 integers and sorts them in descending order.
|
||||
- NumericExpr.pas: A simple program that contains numerical expressions and control flow.
|
||||
-
|
||||
## Usage
|
||||
|
||||
>`$ g++ -O3 -DNDEBUG AwesomePascal.cpp -o BP`
|
||||
>`$ ./BP InsersionSort.pas`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user