Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions ColorzCore/App.config

This file was deleted.

134 changes: 10 additions & 124 deletions ColorzCore/ColorzCore.csproj
Original file line number Diff line number Diff line change
@@ -1,124 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B98F7CCF-9CAA-406E-88D7-2040FA99F631}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ColorzCore</RootNamespace>
<AssemblyName>ColorzCore</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == '32bit|AnyCPU'">
<OutputPath>bin\32bit\</OutputPath>
<PlatformTarget>x86</PlatformTarget>
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EAOptions.cs" />
<Compile Include="DataTypes\CaseInsensitiveString.cs" />
<Compile Include="EAInterpreter.cs" />
<Compile Include="DataTypes\Extension.cs" />
<Compile Include="DataTypes\ImmutableStack.cs" />
<Compile Include="DataTypes\Location.cs" />
<Compile Include="DataTypes\Maybe.cs" />
<Compile Include="DataTypes\MergeableGenerator.cs" />
<Compile Include="DataTypes\Either.cs" />
<Compile Include="IO\ASM.cs" />
<Compile Include="IO\IOUtility.cs" />
<Compile Include="IO\IOutput.cs" />
<Compile Include="IO\ROM.cs" />
<Compile Include="Lexer\Token.cs" />
<Compile Include="Lexer\Tokenizer.cs" />
<Compile Include="Lexer\TokenType.cs" />
<Compile Include="Parser\AST\AtomNodeKernel.cs" />
<Compile Include="Parser\AST\BlockNode.cs" />
<Compile Include="Parser\AST\DataNode.cs" />
<Compile Include="Parser\AST\IAtomNode.cs" />
<Compile Include="Parser\AST\IdentifierNode.cs" />
<Compile Include="Parser\AST\ILineNode.cs" />
<Compile Include="Parser\AST\IParamNode.cs" />
<Compile Include="Parser\AST\ListNode.cs" />
<Compile Include="Parser\AST\MacroInvocationNode.cs" />
<Compile Include="Parser\AST\NegationNode.cs" />
<Compile Include="Parser\AST\NumberNode.cs" />
<Compile Include="Parser\AST\OperatorNode.cs" />
<Compile Include="Parser\AST\ParamType.cs" />
<Compile Include="Parser\AST\RawNode.cs" />
<Compile Include="Parser\AST\StatementNode.cs" />
<Compile Include="Parser\AST\StringNode.cs" />
<Compile Include="Parser\BaseClosure.cs" />
<Compile Include="Parser\Macros\BuiltInMacro.cs" />
<Compile Include="Parser\Macros\IMacro.cs" />
<Compile Include="Parser\Macros\MacroCollection.cs" />
<Compile Include="Parser\Macros\String.cs" />
<Compile Include="Parser\Closure.cs" />
<Compile Include="Parser\Definition.cs" />
<Compile Include="Parser\Macros\Macro.cs" />
<Compile Include="Parser\EAParser.cs" />
<Compile Include="Preprocessor\Directives\UndefineDirective.cs" />
<Compile Include="Preprocessor\Directives\DefineDirective.cs" />
<Compile Include="Preprocessor\Directives\ElseDirective.cs" />
<Compile Include="Preprocessor\Directives\IDirective.cs" />
<Compile Include="Preprocessor\Directives\EndIfDirective.cs" />
<Compile Include="Preprocessor\Directives\IfNotDefinedDirective.cs" />
<Compile Include="Preprocessor\Directives\IfDefinedDirective.cs" />
<Compile Include="Preprocessor\Directives\IncludeBinaryDirective.cs" />
<Compile Include="Preprocessor\Directives\IncludeDirective.cs" />
<Compile Include="Preprocessor\Directives\IncludeToolEventDirective.cs" />
<Compile Include="Preprocessor\Directives\IncludeExternalDirective.cs" />
<Compile Include="Preprocessor\DirectiveHandler.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Raws\AtomicParam.cs" />
<Compile Include="ExecTimer.cs" />
<Compile Include="Raws\Flag.cs" />
<Compile Include="Raws\IRawParam.cs" />
<Compile Include="Raws\ListParam.cs" />
<Compile Include="Raws\Raw.cs" />
<Compile Include="IO\Log.cs" />
<Compile Include="IO\IncludeFileSearcher.cs" />
<Compile Include="Parser\Macros\IsDefined.cs" />
<Compile Include="Parser\Macros\AddToPool.cs" />
<Compile Include="Preprocessor\Directives\PoolDirective.cs" />
<Compile Include="Parser\Pool.cs" />
<Compile Include="Raws\RawReader.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
44 changes: 16 additions & 28 deletions ColorzCore/ColorzCore.sln
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorzCore", "ColorzCore.csproj", "{B98F7CCF-9CAA-406E-88D7-2040FA99F631}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
32bit|Any CPU = 32bit|Any CPU
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B98F7CCF-9CAA-406E-88D7-2040FA99F631}.32bit|Any CPU.ActiveCfg = 32bit|Any CPU
{B98F7CCF-9CAA-406E-88D7-2040FA99F631}.32bit|Any CPU.Build.0 = 32bit|Any CPU
{B98F7CCF-9CAA-406E-88D7-2040FA99F631}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B98F7CCF-9CAA-406E-88D7-2040FA99F631}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B98F7CCF-9CAA-406E-88D7-2040FA99F631}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B98F7CCF-9CAA-406E-88D7-2040FA99F631}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {21D63160-BE4B-46B7-995A-04D8AC7B4472}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorzCore", "ColorzCore.csproj", "{CFFB1609-2FCD-42E9-B335-C9C86F7DD5EC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CFFB1609-2FCD-42E9-B335-C9C86F7DD5EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFFB1609-2FCD-42E9-B335-C9C86F7DD5EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFFB1609-2FCD-42E9-B335-C9C86F7DD5EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFFB1609-2FCD-42E9-B335-C9C86F7DD5EC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
19 changes: 8 additions & 11 deletions ColorzCore/IO/IOUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

Expand All @@ -22,17 +23,13 @@ public static string UnescapePath(string param)
return sb.Replace("\\ ", " ").Replace("\\\\", "\\").ToString();
}

public static string GetToolFileName(string name)
{
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32Windows: // Who knows, maybe someone runs EA on win 95
case PlatformID.Win32NT:
return name + ".exe";

default:
return name;
}
public static string GetToolFileName(string name)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
return name + ".exe";
} else {
return name;
}
}
}
}
60 changes: 40 additions & 20 deletions ColorzCore/Parser/EAParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class EAParser
public MacroCollection Macros { get; }
public Dictionary<string, Definition> Definitions { get; }
public Dictionary<string, IList<Raw>> Raws { get; }
public static readonly HashSet<string> SpecialCodes = new HashSet<string> { "ORG", "PUSH", "POP", "MESSAGE", "WARNING", "ERROR", "ASSERT", "PROTECT", "ALIGN", "FILL" };
public static readonly HashSet<string> SpecialCodes = new HashSet<string> { "ORG", "PUSH", "POP", "MESSAGE", "WARNING", "ERROR", "ASSERT", "PROTECT", "ALIGN", "FILL", "BASE64" };
//public static readonly HashSet<string> BuiltInMacros = new HashSet<string> { "String", "AddToPool" };
//TODO: Built in macros.
//public static readonly Dictionary<string, BuiltInMacro(?)> BuiltInMacros;
Expand Down Expand Up @@ -278,49 +278,69 @@ private Maybe<ILineNode> ParseStatement(MergeableGenerator<Token> tokens, Immuta
}),
() => { Error(parameters[0].MyLocation, "Expected atomic param to ALIGN"); }
);
break;
break;
case "FILL":
if (parameters.Count > 2 || parameters.Count == 0)
{
Error(head.Location, "Incorrect number of parameters in FILL: " + parameters.Count);
if (parameters.Count > 2 || parameters.Count == 0)
{
Error(head.Location, "Incorrect number of parameters in FILL: " + parameters.Count);
}
else
else
{
// FILL <amount> [value]

int amount = 0;
int value = 0;

int value = 0;
if (parameters.Count == 2)
{
// param 2 (if given) is fill value

parameters[1].AsAtom().IfJust(
(IAtomNode atom) => atom.TryEvaluate((Exception e) => { Error(parameters[0].MyLocation, e.Message); }).IfJust(
(IAtomNode atom) => atom.TryEvaluate((Exception e) => { Error(parameters[0].MyLocation, e.Message); }).IfJust(
(int val) => { value = val; }),
() => { Error(parameters[0].MyLocation, "Expected atomic param to FILL"); });
}
}

// param 1 is amount of bytes to fill
// param 1 is amount of bytes to fill
parameters[0].AsAtom().IfJust(
(IAtomNode atom) => atom.TryEvaluate((Exception e) => { Error(parameters[0].MyLocation, e.Message); }).IfJust(
(int val) => { amount = val; }),
() => { Error(parameters[0].MyLocation, "Expected atomic param to FILL"); });
(IAtomNode atom) => atom.TryEvaluate((Exception e) => { Error(parameters[0].MyLocation, e.Message); }).IfJust(
(int val) => { amount = val; }),
() => { Error(parameters[0].MyLocation, "Expected atomic param to FILL"); });

var data = new byte[amount];

for (int i = 0; i < amount; ++i)
data[i] = (byte) value;
data[i] = (byte) value;

var node = new DataNode(CurrentOffset, data);

var node = new DataNode(CurrentOffset, data);

CheckDataWrite(amount);
CurrentOffset += amount;

return new Just<ILineNode>(node);
return new Just<ILineNode>(node);
}

break;
case "BASE64": {
if (parameters.Count != 1)
{
Error(head.Location, "Incorrect number of parameters in BASE64: " + parameters.Count);
}
var paramStr = parameters[0].ToString();
try {
if (string.IsNullOrWhiteSpace(paramStr)) {
throw new FormatException();
}
var data = Convert.FromBase64String(paramStr);
var node = new DataNode(CurrentOffset, data);
CheckDataWrite(data.Length);
CurrentOffset += data.Length;
return new Just<ILineNode>(node);
} catch (FormatException e) {
Error(head.Location, "Invalid base64 string: " + parameters[0].ToString());
}
break;
}
}
return new Nothing<ILineNode>();
}
Expand Down
18 changes: 9 additions & 9 deletions ColorzCore/Preprocessor/Directives/IncludeDirective.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using ColorzCore.Parser.AST;
using System.IO;
using ColorzCore.Parser;
using ColorzCore.IO;

using ColorzCore.IO;
namespace ColorzCore.Preprocessor.Directives
{
class IncludeDirective : IDirective
Expand All @@ -18,13 +18,13 @@ class IncludeDirective : IDirective

public int? MaxParams { get { return 1; } }

public bool RequireInclusion { get { return true; } }

public bool RequireInclusion { get { return true; } }
public IncludeFileSearcher FileSearcher { get; set; }

public Maybe<ILineNode> Execute(EAParser p, Token self, IList<IParamNode> parameters, MergeableGenerator<Token> tokens)
{
Maybe<string> existantFile = FileSearcher.FindFile(Path.GetDirectoryName(self.FileName), parameters[0].ToString());
public Maybe<ILineNode> Execute(EAParser p, Token self, IList<IParamNode> parameters, MergeableGenerator<Token> tokens) {
var file = parameters[0].ToString().Replace("\\", "/");
Maybe<string> existantFile = FileSearcher.FindFile(Path.GetDirectoryName(self.FileName), file);

if (!existantFile.IsNothing)
{
Expand All @@ -38,12 +38,12 @@ public Maybe<ILineNode> Execute(EAParser p, Token self, IList<IParamNode> parame
}
catch(Exception)
{
p.Error(self.Location, "Error reading file \"" + parameters[0].ToString() + "\".");
p.Error(self.Location, "Error reading file \"" + file + "\".");
}
}
else
{
p.Error(parameters[0].MyLocation, "Could not find file \"" + parameters[0].ToString() + "\".");
p.Error(parameters[0].MyLocation, "Could not find file \"" + file + "\".");
}
return new Nothing<ILineNode>();
}
Expand Down
Loading