Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new features (April~May 2024) #63

Merged
merged 61 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f3712e4
port to .NET 5 and enable Nullable
StanHash Jan 31, 2021
54bb84d
remove build output
StanHash Jan 31, 2021
97eaa50
Merge remote-tracking branch 'feu/master' into dotnet
StanHash Feb 10, 2021
b2d224a
set target framework to .NET 6 (latest LTS)
StanHash Sep 8, 2022
d9c49f8
Merge remote-tracking branch 'feu/master' into dotnet
StanHash May 4, 2023
4b72686
fix bad merge
StanHash May 4, 2023
67af0b2
update gitignore because I think sme broke it
StanHash May 25, 2023
7a5df38
ORG allows addresses, POIN allows anything + extra options
StanHash Apr 15, 2024
3f87c6c
fix some warnings
StanHash Apr 15, 2024
840086d
refactor use of Maybe
StanHash Apr 16, 2024
f1c9656
add conditional operators, fallback raws, some qol
StanHash Apr 17, 2024
2d56cd7
add #if directive
StanHash Apr 17, 2024
f425f9f
add alternative projet targetting traditional .NET framework
StanHash Apr 17, 2024
4d820ac
basic symbol assignment
StanHash Apr 17, 2024
5a732ca
add binary negation (bit flip) operator
StanHash Apr 18, 2024
d421357
symbol assignment can be lazy
StanHash Apr 18, 2024
2c6f67f
'??' operator + ASSERT changes + fixes
StanHash Apr 19, 2024
4187197
purge remains of Maybe
StanHash Apr 19, 2024
f11127a
fix macros treating vectors as multiple parameters
StanHash Apr 19, 2024
b2dca34
IsSymbolDefined built-in macro
StanHash Apr 19, 2024
2afb563
better error message when macro expansion doesn't result in valid sta…
StanHash Apr 19, 2024
194e24f
print better messages using format strings
StanHash Apr 19, 2024
69e5025
fixes to format string
StanHash Apr 20, 2024
ee90e8f
don't simplify parameters too early (broke ASSERT hack)
StanHash Apr 20, 2024
c289b64
refactor directive input
StanHash Apr 23, 2024
2ba1770
merge both ifdef with ifndef into one class
StanHash Apr 23, 2024
bd103bb
add ReadByteAt (and friends) built-in macro
StanHash Apr 23, 2024
07eb1a6
relocate macros to preprocessor
StanHash Apr 26, 2024
1fbbe8a
fix define
StanHash Apr 26, 2024
c8e0bda
refactor define (allow any token sequence) + non-productive definitions
StanHash Apr 26, 2024
95e2dd5
add very basic and bad and incomplete testing script
StanHash Apr 26, 2024
f4b7370
move Definition to Preprocessor namespace
StanHash Apr 26, 2024
b74b504
Add rudimentary __LINE__ support
StanHash Apr 26, 2024
58f6f74
Remember macro expansion location chain + working __FILE__
StanHash Apr 26, 2024
17918ff
warn on non-portable paths on windows + update vs solution
StanHash Apr 27, 2024
38a66cd
labels are now addresses
StanHash Apr 27, 2024
32ff5c9
refactor EAOptions
StanHash Apr 27, 2024
9376334
warn on suspicious expansion of macro featuring unguarded operators
StanHash Apr 27, 2024
7a4d069
allow tuning of warnings and extensions via commandline
StanHash Apr 27, 2024
3608375
attempt at a better diagnostic reguarding unintuitive expressions fro…
StanHash Apr 28, 2024
55fdf64
adjustments
StanHash Apr 28, 2024
b7596c7
fixes
StanHash Apr 28, 2024
0f48430
major parser restructuration
StanHash Apr 29, 2024
2efee5b
decouple parse from interpretation
StanHash Apr 29, 2024
1493cf2
change AST production
StanHash Apr 29, 2024
898ceee
UTF8, BASE64, directive refactor, better undef , less leaky CurrentOf…
StanHash Apr 30, 2024
8181f3f
add more tests + fix PROTECT 0
StanHash Apr 30, 2024
fe6d4aa
add tests gitignore
StanHash Apr 30, 2024
cf37d5d
fixes
StanHash May 1, 2024
ccc0350
add extra tests
StanHash May 1, 2024
9487fc3
SetSymbol macro detection, parse fixes, many small internal simplific…
StanHash May 4, 2024
0b10055
fix compile, UTF8 -> STRING, replace error with warning for some spec…
StanHash May 4, 2024
e0072f0
put parts Parser goes into new Interpreter namespace. rename EAInterp…
StanHash May 4, 2024
f443830
tbl and custom encoding support
StanHash May 4, 2024
4eee176
token location fixes
StanHash May 4, 2024
79d803f
do not translate offset 0 to address 0 except for POIN
StanHash May 4, 2024
0a474d0
fix STRING with no encoding + fix tests
StanHash May 4, 2024
3c2f369
fix major a oopsie (multi-line comments broke)
StanHash May 4, 2024
08dff62
fix "garbage" characters printed on Windows cmd (ANSI terminal escape…
StanHash May 4, 2024
5e5126a
remove many unused classes and methods
StanHash May 5, 2024
ead413d
add more tests
StanHash May 5, 2024
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
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################
ColorzCore/obj
ColorzCore/.vs
obj/
bin/
.vs/
*.cache
6 changes: 0 additions & 6 deletions ColorzCore/App.config

This file was deleted.

10 changes: 10 additions & 0 deletions ColorzCore/ColorzCore.Framework.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>annotations</Nullable>
<AssemblyName>ColorzCore</AssemblyName>
<LangVersion>9</LangVersion>
<BaseOutputPath>bin/Framework</BaseOutputPath>
</PropertyGroup>
</Project>
125 changes: 5 additions & 120 deletions ColorzCore/ColorzCore.csproj
Original file line number Diff line number Diff line change
@@ -1,124 +1,9 @@
<?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')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B98F7CCF-9CAA-406E-88D7-2040FA99F631}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>ColorzCore</RootNamespace>
<AssemblyName>ColorzCore</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Nullable>enable</Nullable>
<LangVersion>9</LangVersion>
<BaseOutputPath>bin/Core</BaseOutputPath>
</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>
14 changes: 11 additions & 3 deletions ColorzCore/ColorzCore.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.6
# Visual Studio Version 17
VisualStudioVersion = 17.9.34714.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorzCore", "ColorzCore.csproj", "{B98F7CCF-9CAA-406E-88D7-2040FA99F631}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorzCore", "ColorzCore.csproj", "{B98F7CCF-9CAA-406E-88D7-2040FA99F631}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorzCore.Framework", "ColorzCore.Framework.csproj", "{33DC9CB0-82AB-47EC-9D7F-AD9FD5776BCF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -18,6 +20,12 @@ Global
{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
{33DC9CB0-82AB-47EC-9D7F-AD9FD5776BCF}.32bit|Any CPU.ActiveCfg = Debug|Any CPU
{33DC9CB0-82AB-47EC-9D7F-AD9FD5776BCF}.32bit|Any CPU.Build.0 = Debug|Any CPU
{33DC9CB0-82AB-47EC-9D7F-AD9FD5776BCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33DC9CB0-82AB-47EC-9D7F-AD9FD5776BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33DC9CB0-82AB-47EC-9D7F-AD9FD5776BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33DC9CB0-82AB-47EC-9D7F-AD9FD5776BCF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
36 changes: 0 additions & 36 deletions ColorzCore/DataTypes/CaseInsensitiveString.cs

This file was deleted.

8 changes: 4 additions & 4 deletions ColorzCore/DataTypes/Either.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public interface Either<Left, Right>
bool IsRight { get; }
Left GetLeft { get; }
Right GetRight { get; }
void Case(TAction<Left> LAction, TAction<Right> RAction);
void Case(Action<Left> LAction, Action<Right> RAction);
}
public class Left<L, R> : Either <L, R>
public class Left<L, R> : Either<L, R>
{
public Left(L val)
{
Expand All @@ -27,7 +27,7 @@ public Left(L val)
public bool IsRight { get { return false; } }
public L GetLeft { get; }
public R GetRight { get { throw new WrongEitherException(); } }
public void Case(TAction<L> LAction, TAction<R> RAction) { LAction(GetLeft); }
public void Case(Action<L> LAction, Action<R> RAction) { LAction(GetLeft); }
}
public class Right<L, R> : Either<L, R>
{
Expand All @@ -40,7 +40,7 @@ public Right(R val)
public bool IsRight { get { return true; } }
public L GetLeft { get { throw new WrongEitherException(); } }
public R GetRight { get; }
public void Case(TAction<L> LAction, TAction<R> RAction) { RAction(GetRight); }
public void Case(Action<L> LAction, Action<R> RAction) { RAction(GetRight); }
}
class WrongEitherException : Exception { }
}
57 changes: 29 additions & 28 deletions ColorzCore/DataTypes/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static int ToInt(this string numString)
}
}
public static Dictionary<K, IList<V>> AddTo<K,V>(this Dictionary<K, IList<V>> self, K key, V val)
where K: notnull
{
if (self.ContainsKey(key))
self[key].Add(val);
Expand All @@ -58,19 +59,19 @@ public static Dictionary<K, IList<V>> AddTo<K,V>(this Dictionary<K, IList<V>> se
self[key] = new List<V> { val };
}
return self;
}

}
public static void SetBits(this byte[] array, int bitOffset, int bitSize, int value)
{
array.SetBits(0, bitOffset, bitSize, value);
}

public static void SetBits(this byte[] array, int byteOffset, int bitOffset, int bitSize, int value)
{
if (bitOffset >= 8)
if (bitOffset >= 8)
{
array.SetBits(byteOffset + bitOffset / 8, bitOffset % 8, bitSize, value);
return;
return;
}

long bytes = 0;
Expand All @@ -95,48 +96,48 @@ public static void SetBits(this byte[] array, int byteOffset, int bitOffset, int
array[byteOffset + i] = (byte)(bytes >> i * 8);
}

public static void SetBits(this byte[] array, int bitOffset, int bitSize, byte[] data)
{
array.SetBits(0, bitOffset, bitSize, data);
public static void SetBits(this byte[] array, int bitOffset, int bitSize, byte[] data)
{
array.SetBits(0, bitOffset, bitSize, data);
}

public static void SetBits(this byte[] array, int byteOffset, int bitOffset, int bitSize, byte[] data)
{
if (bitOffset >= 8)
public static void SetBits(this byte[] array, int byteOffset, int bitOffset, int bitSize, byte[] data)
{
if (bitOffset >= 8)
{
array.SetBits(byteOffset + bitOffset / 8, bitOffset % 8, bitSize, data);
return;
return;
}

int byteSize = (bitOffset + bitSize + 7) / 8;

if (bitOffset == 0)
{
if (bitOffset == 0)
{
for (int i = 0; i < byteSize - 1; ++i)
array[byteOffset + i] = data[i];

int shift = bitSize % 8 == 0 ? 8 : bitSize % 8;
uint endMask = (uint)((1 << shift) - 1);

array[byteOffset + byteSize - 1] &= (byte)~endMask;
array[byteOffset + byteSize - 1] |= (byte)(data[byteSize - 1] & endMask);
array[byteOffset + byteSize - 1] |= (byte)(data[byteSize - 1] & endMask);
}
else
{
for (int i = 0; i < byteSize; ++i)
{
int mask = ((1 << Math.Min(bitSize - i * 8, 8)) - 1) << bitOffset;

byte loMask = (byte)mask;
byte hiMask = (byte)(mask >> 8);

array[byteOffset + i] &= (byte)~loMask;
array[byteOffset + i] |= (byte)((data[i] << bitOffset) & loMask);

array[byteOffset + i + 1] &= (byte)~hiMask;
array[byteOffset + i + 1] |= (byte)((data[i] >> (8 - bitOffset)) & hiMask);
{
for (int i = 0; i < byteSize; ++i)
{
int mask = ((1 << Math.Min(bitSize - i * 8, 8)) - 1) << bitOffset;
byte loMask = (byte)mask;
byte hiMask = (byte)(mask >> 8);
array[byteOffset + i] &= (byte)~loMask;
array[byteOffset + i] |= (byte)((data[i] << bitOffset) & loMask);
array[byteOffset + i + 1] &= (byte)~hiMask;
array[byteOffset + i + 1] |= (byte)((data[i] >> (8 - bitOffset)) & hiMask);
}
}
}
}
}
}
Loading