From 00aaf4da36347af40a4f3fdedb93b515588fd695 Mon Sep 17 00:00:00 2001 From: Avril Date: Wed, 8 Jul 2020 17:43:21 +0100 Subject: [PATCH] initial commit --- .gitignore | 362 +++++++++++++++++++++++ libsex.sln | 31 ++ libsex/Class1.cs | 411 ++++++++++++++++++++++++++ libsex/libsex.csproj | 7 + test/Program.cs | 29 ++ test/Properties/Resources.Designer.cs | 92 ++++++ test/Properties/Resources.resx | 124 ++++++++ test/Resources/Example.txt | 28 ++ test/test.csproj | 27 ++ 9 files changed, 1111 insertions(+) create mode 100644 .gitignore create mode 100644 libsex.sln create mode 100644 libsex/Class1.cs create mode 100644 libsex/libsex.csproj create mode 100644 test/Program.cs create mode 100644 test/Properties/Resources.Designer.cs create mode 100644 test/Properties/Resources.resx create mode 100644 test/Resources/Example.txt create mode 100644 test/test.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ee5385 --- /dev/null +++ b/.gitignore @@ -0,0 +1,362 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd diff --git a/libsex.sln b/libsex.sln new file mode 100644 index 0000000..9943dc7 --- /dev/null +++ b/libsex.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29609.76 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libsex", "libsex\libsex.csproj", "{163D3AE6-B930-41F5-BCB6-E11E42EF495B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "test", "test\test.csproj", "{52FACECB-29A6-4205-96E1-8DD964B7E9CB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {163D3AE6-B930-41F5-BCB6-E11E42EF495B}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {163D3AE6-B930-41F5-BCB6-E11E42EF495B}.Debug|Any CPU.Build.0 = Release|Any CPU + {163D3AE6-B930-41F5-BCB6-E11E42EF495B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {163D3AE6-B930-41F5-BCB6-E11E42EF495B}.Release|Any CPU.Build.0 = Release|Any CPU + {52FACECB-29A6-4205-96E1-8DD964B7E9CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52FACECB-29A6-4205-96E1-8DD964B7E9CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52FACECB-29A6-4205-96E1-8DD964B7E9CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52FACECB-29A6-4205-96E1-8DD964B7E9CB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {02ABDF0E-E764-4C26-82F3-CF957EBBCC42} + EndGlobalSection +EndGlobal diff --git a/libsex/Class1.cs b/libsex/Class1.cs new file mode 100644 index 0000000..e78664a --- /dev/null +++ b/libsex/Class1.cs @@ -0,0 +1,411 @@ +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading; + +namespace libsex +{ + [Serializable] + public class SExpression : IList + { + private readonly List inter = new List(); + + public SExpression() + { + + } + + public static SExpression Concat(params SExpression[] sexs) + { + var sex = new SExpression(); + sex.inter.AddRange(sexs); + return sex; + } + + public object Car() + => inter.Count < 1 ? null : inter[0]; + public SExpression Cdr() + { + if (inter.Count < 2) return new SExpression(); + else return new SExpression(inter.Skip(1)); + } + + public SExpression IPWhere(Func predicate) + { + var add = inter.Where(predicate).ToArray(); + inter.Clear(); + inter.AddRange(add); + return this; + } + + public SExpression IPSelect(Func transform) + { + var add = inter.Select(transform).ToArray(); + inter.Clear(); + inter.AddRange(add); + return this; + } + + public SExpression Take(Func transform) + { + SExpression sexpr = new SExpression(); + foreach (var obj in inter.ToArray()) + { + if (transform(obj)) + { + sexpr.Add(obj); + inter.Remove(obj); + } + } + return sexpr; + } + + public string CarString() => Car() as string; + + public SExpression CarExpr() => Car() switch { SExpression sex => sex, IEnumerable ie => new SExpression(ie), _ => null }; + + public T Car(T or = default) => Car() is T t ? t : or; + + public SExpression(params object[] initial) + { + inter.AddRange(initial); + } + + public object[] Slice(int start,int length) + { + object[] slice = new object[length]; + inter.CopyTo(start, slice, 0, length); + return slice; + } + + public object Path(params int[] indecies) + { + IList elements = this.inter; + for (int i = 0; i < indecies.Length; i++) + { + int index = indecies[i]; + if (index < 0 || index >= elements.Count) throw new IndexOutOfRangeException("Index " + i + " (" + index + ") was out of bounds."); + else + { + if (elements[index] is IList il) + { + elements = il; + } + else return elements[index]; + } + } + return elements; + } + + public SExpression(IEnumerable from) + { + inter.AddRange(from); + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + //sb.Append("("); + + foreach (var item in inter) + { + if (item is SExpression se) + sb.Append("(" + se.ToString() + ")"); + else if (item is string str) + sb.Append(escape(str)); + else if (item is IEnumerable il) + sb.Append("(" + new SExpression(il).ToString() + ")"); + else if (item is IEnumerable li) + { + SExpression sex = new SExpression(); + foreach (var o in li) + { + sex.inter.Add(o); + } + sb.Append("(" + sex.ToString() + ")"); + } + else sb.Append(escape(item.ToString())); + sb.Append(" "); + } + + return sb.ToString().Trim();// + ")"; + } + + public SExpression FlattenTopLevel(bool full=false) + { + if (full) while (inter.Count == 1 && inter[0] is SExpression se) + { + inter.Clear(); + inter.AddRange(se.inter); + } + else if (inter.Count == 1 && inter[0] is SExpression se) + { + inter.Clear(); + inter.AddRange(se.inter); + } + return this; + } + + private static readonly System.Text.RegularExpressions.Regex escape_re = new System.Text.RegularExpressions.Regex(@"[\s\(\)]", System.Text.RegularExpressions.RegexOptions.Compiled); + private string escape(string str) + { + str = str.Replace("\\", "\\\\"); + str = str.Replace("\"", "\\\""); + if (escape_re.IsMatch(str)) return $"\"{str}\""; + else return str; + } + + #region IList + public object this[int index] { get => inter[index]; set => inter[index] = value; } + + public int Count => inter.Count; + + public bool IsReadOnly => false; + + public void Add(object item) + { + inter.Add(item); + } + + public void Clear() + { + inter.Clear(); + } + + public bool Contains(object item) + { + return inter.Contains(item); + } + + public void CopyTo(object[] array, int arrayIndex) + { + inter.CopyTo(array, arrayIndex); + } + + public IEnumerator GetEnumerator() + { + return inter.GetEnumerator(); + } + + public int IndexOf(object item) + { + return inter.IndexOf(item); + } + + public void Insert(int index, object item) + { + inter.Insert(index, item); + } + + public bool Remove(object item) + { + return inter.Remove(item); + } + + public void RemoveAt(int index) + { + inter.RemoveAt(index); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return (inter as IEnumerable).GetEnumerator(); + } + #endregion + + private static async Task parse(AsyncConsumer input) + { + SExpression main = new SExpression(); + var (isEscaped, isStringed) = (false, false); + StringBuilder token = new StringBuilder(); + + void addToken() + { + if (token.Length > 0) + main.inter.Add(token.ToString()); + token.Clear(); + } + + (char, bool) ok; + while ((ok = await input.TryTake()).Item2) + { + var letter = ok.Item1; + if (isEscaped) + { + token.Append(letter); + isEscaped = false; + } + else if (letter == '\\') + { + isEscaped = true; + } + else if (isStringed) + { + if (letter == '"') isStringed = false; + else token.Append(letter); + } + else if (letter == '(') + { + addToken(); + main.inter.Add(await parse(input)); + } + else if (letter == ')') + { + addToken(); + return main; + } + else if (letter == ' ' || letter == '\t' || letter == '\n' || letter == '\r' || letter == '\f') + { + addToken(); + } + else if (letter == '"') + { + isStringed = true; + } + else token.Append(letter); + } + + addToken(); + return main; + } + + + private static async IAsyncEnumerable preprocess(IAsyncEnumerable input) + { + var (isEscaped, isStringed, isCommented) = (false, false, false); + await foreach (var letter in input) + { + if (isEscaped) + { + yield return letter; + isEscaped = false; + } + else if (letter == '\\') + { + isEscaped = true; + yield return letter; + } + else if (isStringed) + { + yield return letter; + if (letter == '"') isStringed = false; + } + else if (isCommented) + { + if (letter == '\n' || letter == '\r' || letter == '\f') + { + yield return '\n'; + isCommented = false; + } + } + else if (letter == '"') + { + isStringed = true; + yield return letter; + } + else if (letter == ';') + { + isCommented = true; + } + else if (letter == '\t') + { + yield return ' '; + } + else yield return letter; + + } + } + + public static async Task ParseAsync(IAsyncEnumerable str) + { + AsyncConsumer s; + var res = await parse(s = new AsyncConsumer(preprocess(str))); + await s.DisposeAsync(); + return res; + } + + public static async IAsyncEnumerable ParseMultipleAsync(IAsyncEnumerable str, [EnumeratorCancellation] CancellationToken token = default) + { + str = preprocess(str); + + await using var consumer = new AsyncConsumer(str); + + (char, bool) cur = default; + while ((await consumer.TryTake(token)).Item2) + { + if(cur.Item1 == '(') + { + yield return await parse(consumer); + } + } + } + + public static SExpression Parse(IEnumerable str) + { + async IAsyncEnumerable interop() + { + await Task.Yield(); + foreach (var s in str) yield return s; + } + try + { + var awaiter = ParseAsync(interop()); + awaiter.Wait(); + if (awaiter.IsFaulted) throw awaiter.Exception; + return awaiter.Result; + } + catch (Exception ex) { throw ex; } + } + } + + + class AsyncConsumer : IAsyncDisposable + { + readonly IAsyncEnumerator e; + public AsyncConsumer(IAsyncEnumerable input) + { + e = input.GetAsyncEnumerator(); + } + + public async ValueTask DisposeAsync() + { + await e.DisposeAsync(); + } + + public async ValueTask<(T, bool)> TryTake(CancellationToken token) + { + if (token == default) return await TryTake(); + + TaskCompletionSource cancel = new TaskCompletionSource(); + using var _c = token.Register(() => cancel.SetResult(false)); + var res = e.MoveNextAsync().AsTask(); + if (await Task.WhenAny(res, cancel.Task) == res) + { + var ok = res.Result; + if (ok) + { + return (e.Current, true); + } + else return (default, false); + } + else + throw new OperationCanceledException(); + } + + public async ValueTask<(T, bool)> TryTake() + { + var ok = await e.MoveNextAsync(); + if (ok) + { + return (e.Current, true); + } + else return (default, false); + } + } +} diff --git a/libsex/libsex.csproj b/libsex/libsex.csproj new file mode 100644 index 0000000..f51c9c8 --- /dev/null +++ b/libsex/libsex.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.1 + + + diff --git a/test/Program.cs b/test/Program.cs new file mode 100644 index 0000000..bf73fa9 --- /dev/null +++ b/test/Program.cs @@ -0,0 +1,29 @@ +using System; +using libsex; + +namespace test +{ + class Program + { + static void Main(string[] args) + { + SExpression sex = SExpression.Parse(global::test.Properties.Resources.Example); + + string sex1Str = sex.ToString(); + + var sex2 = SExpression.Parse(sex1Str); + + string sex2Str = sex2.ToString(); + + Console.WriteLine(sex1Str); + Console.WriteLine(sex2Str); + + Console.WriteLine("----"); + + Console.WriteLine(sex1Str == sex2Str); + Console.WriteLine(sex.Path(0, 1, 0)); + + Console.ReadKey(); + } + } +} diff --git a/test/Properties/Resources.Designer.cs b/test/Properties/Resources.Designer.cs new file mode 100644 index 0000000..31ccf65 --- /dev/null +++ b/test/Properties/Resources.Designer.cs @@ -0,0 +1,92 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace test.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("test.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to ;; ISS3 config template + ///(progn + /// (native cfg) + /// (native perm) + /// + /// (defparameter *all* '(listing images encrypted-listing encrypted-images add edit super)) + /// + /// (defconf + /// (database (prompt "Enter pathname" :string)) + /// (port (prompt "Enter port" :integer)) + /// (allow + /// '("127.0.0.1" + /// "127.0.0.0/8" + /// "0.0.0.0/0")) + /// (deny + /// '("123.123.123.0/24")) + /// (password nil) + /// (welcome "ISS v3 server.") + /// (key 123456789ABCDEFF) + /// (permissions ;;You can also set file like (permissions "file.lisp") + /// [rest of string was truncated]";. + /// + internal static string Example { + get { + return ResourceManager.GetString("Example", resourceCulture); + } + } + } +} diff --git a/test/Properties/Resources.resx b/test/Properties/Resources.resx new file mode 100644 index 0000000..609d968 --- /dev/null +++ b/test/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\Example.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + \ No newline at end of file diff --git a/test/Resources/Example.txt b/test/Resources/Example.txt new file mode 100644 index 0000000..d14d004 --- /dev/null +++ b/test/Resources/Example.txt @@ -0,0 +1,28 @@ +;; ISS3 config template +(progn + (native cfg) + (native perm) + + (defparameter *all* '(listing images encrypted-listing encrypted-images add edit super)) + + (defconf + (database (prompt "Enter (pathname" :string)) + (port (prompt "Enter port" :integer)) + (allow + '("127.0.0.1" + "127.0.0.0/8" + "0.0.0.0/0")) + (deny + '("123.123.123.0/24")) + (password nil) + (welcome "ISS v3 server.") + (key 123456789ABCDEFF) + (permissions ;;You can also set file like (permissions "file.lisp") + (defperm + (:default '(listing images)) ;;default + (permission-entry :name "entry 1" :public-key 123456789ABCDEFF :level *all*) + (permission-entry :name "entry 2" :password (sha1 "this is password") :level '(listing images encrypted-listing encrypted-images)) + (permission-entry :name "entry 2.5" :password 123456789ABCDEFF :level '(listing images encrypted-listing encrypted-images)) + (permission-entry :name "entry 3" :public-key (keyfile "filename") :level *all*) + (permission-entry :name "entry 3.5" :public-key (keyfile "filename" base64) :level *all*) ;;call base64() on file + (permission-entry :name "entry 4" :public-key (base64 "insert thing here") :level *all*))))) \ No newline at end of file diff --git a/test/test.csproj b/test/test.csproj new file mode 100644 index 0000000..74f289f --- /dev/null +++ b/test/test.csproj @@ -0,0 +1,27 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + +