Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial WIP
  • Loading branch information
Brad Robinson committed Jul 25, 2010
0 parents commit 8687f48
Show file tree
Hide file tree
Showing 41 changed files with 5,193 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
build
bin
obj
Release
Debug
*.pdb
*.user
*.suo
*.swp
*.swo
*.ncb
32 changes: 32 additions & 0 deletions MiniME.sln
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniME", "MiniME\MiniME.csproj", "{947703CB-0944-4609-A4C3-B85B90DF50E1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mm", "mm\mm.csproj", "{692B99CE-C938-43AE-9F1F-1DA24557FD14}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniMETestCases", "MiniMETestCases\MiniMETestCases.csproj", "{76CC33AD-D621-431C-8366-C5D4A1C428A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{947703CB-0944-4609-A4C3-B85B90DF50E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{947703CB-0944-4609-A4C3-B85B90DF50E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{947703CB-0944-4609-A4C3-B85B90DF50E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{947703CB-0944-4609-A4C3-B85B90DF50E1}.Release|Any CPU.Build.0 = Release|Any CPU
{692B99CE-C938-43AE-9F1F-1DA24557FD14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{692B99CE-C938-43AE-9F1F-1DA24557FD14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{692B99CE-C938-43AE-9F1F-1DA24557FD14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692B99CE-C938-43AE-9F1F-1DA24557FD14}.Release|Any CPU.Build.0 = Release|Any CPU
{76CC33AD-D621-431C-8366-C5D4A1C428A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76CC33AD-D621-431C-8366-C5D4A1C428A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76CC33AD-D621-431C-8366-C5D4A1C428A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76CC33AD-D621-431C-8366-C5D4A1C428A9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
31 changes: 31 additions & 0 deletions MiniME/CompileError.cs
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MiniME
{
public class CompileError : Exception
{
internal CompileError(string message, Tokenizer t)
{
m_strMessage = message;
m_strFileName = t.FileName;
m_lineNumber = t.currentLine;
m_linePosition = t.currentLinePosition;
}

public override string Message
{
get
{
return string.Format("{0}({1},{2}): {3}", m_strFileName, m_lineNumber+1, m_linePosition+1, m_strMessage);
}
}

string m_strMessage;
string m_strFileName;
int m_lineNumber;
int m_linePosition;
}
}
76 changes: 76 additions & 0 deletions MiniME/Compiler.cs
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MiniME
{
public class Compiler
{
public Compiler()
{
Reset();
}

public TextWriter Output
{
get;
set;
}

public void Reset()
{
m_files.Clear();
}

public void AddFile(string strFileName)
{
var i=new FileInfo();
i.filename=strFileName;
i.content=File.ReadAllText(strFileName);
m_files.Add(i);
}

public void Compile()
{
foreach (var file in m_files)
{
Console.WriteLine("Processing {0}...", file.filename);

// Create a tokenizer and parser
Tokenizer t = new Tokenizer(file.content, file.filename);
Parser p = new Parser(t);

// Parse the file into a namespace
var statements = new ast.StatementBlock();
p.ParseStatements(statements);
statements.GlobalScope = false;

if (t.more)
{
throw new CompileError("Unexpected EOF", t);
}

//statements.Dump(0);
SymbolScope rootScope = new SymbolScope(null);
statements.Visit(new SymbolDeclarationVisitor(rootScope));
statements.Visit(new SymbolUsageVisitor(rootScope));

rootScope.Dump(0);

StringBuilder sb = new StringBuilder();
statements.Render(sb);
Console.WriteLine(sb.ToString());
}
}

class FileInfo
{
public string filename;
public string content;
}

List<FileInfo> m_files=new List<FileInfo>();
}
}
89 changes: 89 additions & 0 deletions MiniME/MiniME.csproj
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{947703CB-0944-4609-A4C3-B85B90DF50E1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MiniME</RootNamespace>
<AssemblyName>MiniME</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ast\StatementTryCatchFinally.cs" />
<Compile Include="ast\StatementWith.cs" />
<Compile Include="ast\StatementForEach.cs" />
<Compile Include="ast\StatementLabel.cs" />
<Compile Include="ast\StatementWhile.cs" />
<Compile Include="ast\StatementDoWhile.cs" />
<Compile Include="ast\StatementBreakContinue.cs" />
<Compile Include="ast\StatementSwitch.cs" />
<Compile Include="ast\StatementExpression.cs" />
<Compile Include="ast\StatementVariableDeclaration.cs" />
<Compile Include="ast\StatementFor.cs" />
<Compile Include="ast\StatementIfElse.cs" />
<Compile Include="ast\ExpressionNode.cs" />
<Compile Include="ast\StatementReturnThrow.cs" />
<Compile Include="ast\Node.cs" />
<Compile Include="ast\Parameter.cs" />
<Compile Include="ast\Statement.cs" />
<Compile Include="ast\StatementBlock.cs" />
<Compile Include="SymbolFrequency.cs" />
<Compile Include="SymbolScope.cs" />
<Compile Include="SymbolUsageVisitor.cs" />
<Compile Include="SymbolDeclarationVisitor.cs" />
<Compile Include="Utils.cs" />
<Compile Include="SymbolManager.cs" />
<Compile Include="CompileError.cs" />
<Compile Include="Compiler.cs" />
<Compile Include="Parser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StringScanner.cs" />
<Compile Include="Tokenizer.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

0 comments on commit 8687f48

Please sign in to comment.