Skip to content

Commit

Permalink
worked on #167
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown6656 committed Apr 17, 2024
1 parent b728be2 commit 79dd353
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 36 deletions.
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
################################################################
# Auto-generated 2024-04-15 23:53:34.354 #
# Auto-generated 2024-04-17 08:12:10.736 #
# ANY CHANGES TO THIS DOCUMENT WILL BE LOST UPON RE-GENERATION #
################################################################
#
# git commit: fc8e83b32164422fe0cbcc8b641fbb42ebe0d778
version: 0.12.2390.8650
# git commit: b728be29d3366955236e5645a70fc5317b5de033
version: 0.12.2392.8652
image: Visual Studio 2022
configuration: Release
install:
Expand Down
16 changes: 8 additions & 8 deletions src/AutoItInterpreter/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

//////////////////////////////////////////////////////////////////////////
// Auto-generated 2024-04-15 23:53:34.354 //
// Auto-generated 2024-04-17 08:12:10.736 //
// ANY CHANGES TO THIS DOCUMENT WILL BE LOST UPON RE-GENERATION //
//////////////////////////////////////////////////////////////////////////

using System.Reflection;
using System;

[assembly: AssemblyVersion("0.12.2390.8650")]
[assembly: AssemblyFileVersion("0.12.2390.8650")]
[assembly: AssemblyInformationalVersion("v.0.12.2390.8650, commit: fc8e83b32164422fe0cbcc8b641fbb42ebe0d778")]
[assembly: AssemblyVersion("0.12.2392.8652")]
[assembly: AssemblyFileVersion("0.12.2392.8652")]
[assembly: AssemblyInformationalVersion("v.0.12.2392.8652, commit: b728be29d3366955236e5645a70fc5317b5de033")]
[assembly: AssemblyCompany("Unknown6656")]
[assembly: AssemblyCopyright("Copyright © 2018 - 2024, Unknown6656")]
[assembly: AssemblyProduct("AutoIt-Interpreter by Unknown6656")]
Expand All @@ -35,11 +35,11 @@ public static class __module__
/// <summary>
/// The interpreter's current version.
/// </summary>
public static Version? InterpreterVersion { get; } = Version.Parse("0.12.2390.8650");
public static Version? InterpreterVersion { get; } = Version.Parse("0.12.2392.8652");
/// <summary>
/// The Git hash associated with the current build.
/// </summary>
public const string GitHash = "fc8e83b32164422fe0cbcc8b641fbb42ebe0d778";
public const string GitHash = "b728be29d3366955236e5645a70fc5317b5de033";
/// <summary>
/// The name of the GitHub repository associated with <see cref="RepositoryURL"/>.
/// </summary>
Expand All @@ -49,7 +49,7 @@ public static class __module__
/// </summary>
public const string RepositoryURL = "https://github.com/Unknown6656/AutoIt-Interpreter";
/// <summary>
/// The date and time of the current build (2024-04-15 23:53:34.354).
/// The date and time of the current build (2024-04-17 08:12:10.736).
/// </summary>
public static DateTime DateBuilt { get; } = DateTime.FromFileTimeUtc(0x01da8f7f5ced8f6dL);
public static DateTime DateBuilt { get; } = DateTime.FromFileTimeUtc(0x01da908e2ee50274L);
}
3 changes: 1 addition & 2 deletions src/AutoItInterpreter/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"profiles": {
"AutoItInterpreter": {
"commandName": "Project",
"commandLineArgs": "-ml ConsoleWrite(@OSVERSION)",
//"commandLineArgs": "../test/hello-world -vv",
"commandLineArgs": "-ml $ -vv",
"nativeDebugging": false
}
}
Expand Down
105 changes: 84 additions & 21 deletions src/AutoItInterpreter/Runtime/ScriptScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,32 @@ namespace Unknown6656.AutoIt3.Runtime;
/// <summary>
/// Represents an AutoIt3 script scanning and caching module.
/// </summary>
public sealed class ScriptScanner
public sealed partial class ScriptScanner
{
private static readonly string[] AUTOIT_FILE_EXTENSIONS = ["", ".au3", ".au2", ".au", ".aupp", ".au++"];

private const RegexOptions REGEX_OPTIONS = RegexOptions.IgnoreCase | RegexOptions.Compiled;
private const string REGEX_FUNC_MODIFIERS = /*lang=regex*/@"((\s+|\b)(?<modifiers>volatile(\s+cached)?|cached(\s+volatile)?)(\s+|\b))?";
private static readonly Regex REGEX_COMMENT = new(@"\;[^\""\']*$", REGEX_OPTIONS);
private static readonly Regex REGEX_COMMENT_AFTER_STRING1 = new(@"^([^\""\;]*\""[^\""]*\""[^\""\;]*)*(?<cmt>\;).*$", REGEX_OPTIONS);
private static readonly Regex REGEX_COMMENT_AFTER_STRING2 = new(@"^([^'\;]*'[^']*'[^'\;]*)*(?<cmt>\;).*$", REGEX_OPTIONS);
internal static readonly Regex REGEX_CS = new(@"^#(comments\-start|cs)(\b|$)", REGEX_OPTIONS);
internal static readonly Regex REGEX_CE = new(@"^#(comments\-end|ce)(\b|$)", REGEX_OPTIONS);
private static readonly Regex REGEX_REGION = new(@"^#(end-?)?region\b", REGEX_OPTIONS);
private static readonly Regex REGEX_PRAGMA = new(@"^#pragma\s+(?<option>[a-z_]\w+)\b\s*(\((?<params>.*)\))?\s*", REGEX_OPTIONS);
private static readonly Regex REGEX_LINECONT = new(@"(\s|^)_$", REGEX_OPTIONS);
private static readonly Regex REGEX_1L_IF = new(@"^\s*(?<if>if\b\s*.+\s*\bthen)\b\s*(?<then>.+)$", REGEX_OPTIONS);
private static readonly Regex REGEX_1L_FUNC = new($@"^(?<decl>{REGEX_FUNC_MODIFIERS}\s*\bfunc\b\s*([a-z_]\w*)\s*\(.*\))\s*->\s*(?<body>.+)$", REGEX_OPTIONS);
private static readonly Regex REGEX_FUNC_ASSG = new($@"^(?<target>.+)=\s*(?<func>{REGEX_FUNC_MODIFIERS}\s*\bfunc)\s*(?<args>\(.*\))$", REGEX_OPTIONS);
private static readonly Regex REGEX_FUNC = new($@"^{REGEX_FUNC_MODIFIERS}\s*\bfunc\s+(?<name>[a-z_]\w*)\s*\((?<args>.*)\)$", REGEX_OPTIONS);
private static readonly Regex REGEX_ENDFUNC = new(@"^endfunc$", REGEX_OPTIONS);
private static readonly Regex REGEX_LABEL = new(@"^(?<name>[a-z_]\w*)\s*:$", REGEX_OPTIONS);
private static readonly Regex REGEX_INCLUDEONCE = new(@"^#include-once(\b|$)", REGEX_OPTIONS);
private static readonly Regex REGEX_AUSTARTREGISTER = new(@"^#(onautoitstartregister\s+""(?<func>[^""]+)"")", REGEX_OPTIONS);
private static readonly Regex REGEX_AUEXITREGISTER = new(@"^#(onautoitexitregister\s+""(?<func>[^""]+)"")", REGEX_OPTIONS);
private static readonly Regex REGEX_REQADMIN = new(@"^#requireadmin\b", REGEX_OPTIONS);
private static readonly Regex REGEX_NOTRYICON = new(@"^#notrayicon\b", REGEX_OPTIONS);


private static readonly Regex REGEX_COMMENT = GenRegex_COMMENT();
private static readonly Regex REGEX_COMMENT_AFTER_STRING1 = GenRegex_COMMENT_AFTER_STRING1();
private static readonly Regex REGEX_COMMENT_AFTER_STRING2 = GenRegex_COMMENT_AFTER_STRING2();
internal static readonly Regex REGEX_CS = GenRegex_CS();
internal static readonly Regex REGEX_CE = GenRegex_CE();
private static readonly Regex REGEX_REGION = GenRegex_REGION();
private static readonly Regex REGEX_PRAGMA = GenRegex_PRAGMA();
private static readonly Regex REGEX_LINECONT = GenRegex_LINECONT();
private static readonly Regex REGEX_1L_IF = GenRegex_1LIF();
private static readonly Regex REGEX_1L_FUNC = GenRegex_1LFUNC();
private static readonly Regex REGEX_FUNC_ASSG = GenRegex_FUNCASSIGNMENT();
private static readonly Regex REGEX_FUNC = GenRegex_FUNC();
private static readonly Regex REGEX_ENDFUNC = GenRegex_ENDFUNC();
private static readonly Regex REGEX_LABEL = GenRegex_LABEL();
private static readonly Regex REGEX_INCLUDEONCE = GenRegex_INCLUDEONCE();
private static readonly Regex REGEX_AUSTARTREGISTER = GenRegex_AUSTARTREGISTER();
private static readonly Regex REGEX_AUEXITREGISTER = GenRegex_AUEXITREGISTER();
private static readonly Regex REGEX_REQADMIN = GenRegex_REQADMIN();
private static readonly Regex REGEX_NOTRYICON = GenRegex_NOTRAYICON();

private static readonly Func<string, (FileInfo physical, string content)?>[] _existing_resolvers =
[
Expand Down Expand Up @@ -436,6 +437,68 @@ private static (FileInfo physical, string content)? ResolveUNC(string path)
private static (FileInfo physical, string content)? ResolveHTTP(string path) => (new FileInfo(path), DataStream.FromWebResource(new Uri(path)).ToString());

private static (FileInfo physical, string content)? ResolveFTP(string path) => (new FileInfo(path), DataStream.FromFTP(path).ToString());


#region Regex generators

[GeneratedRegex(@"^#notrayicon\b", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_NOTRAYICON();

[GeneratedRegex(@"^#requireadmin\b", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_REQADMIN();

[GeneratedRegex(@"^#(onautoitexitregister\s+""(?<func>[^""]+)"")", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_AUEXITREGISTER();

[GeneratedRegex(@"^#(onautoitstartregister\s+""(?<func>[^""]+)"")", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_AUSTARTREGISTER();

[GeneratedRegex(@"^#include-once(\b|$)", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_INCLUDEONCE();

[GeneratedRegex(@"^(?<name>[a-z_]\w*)\s*:$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_LABEL();

[GeneratedRegex(@"^endfunc$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_ENDFUNC();

[GeneratedRegex(@"^((\s+|\b)(?<modifiers>volatile(\s+cached)?|cached(\s+volatile)?)(\s+|\b))?\s*\bfunc\s+(?<name>[a-z_]\w*)\s*\((?<args>.*)\)$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_FUNC();

[GeneratedRegex(@"^(?<target>.+)=\s*(?<func>((\s+|\b)(?<modifiers>volatile(\s+cached)?|cached(\s+volatile)?)(\s+|\b))?\s*\bfunc)\s*(?<args>\(.*\))$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_FUNCASSIGNMENT();

[GeneratedRegex(@"^(?<decl>((\s+|\b)(?<modifiers>volatile(\s+cached)?|cached(\s+volatile)?)(\s+|\b))?\s*\bfunc\b\s*([a-z_]\w*)\s*\(.*\))\s*->\s*(?<body>.+)$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_1LFUNC();

[GeneratedRegex(@"^\s*(?<if>if\b\s*.+\s*\bthen)\b\s*(?<then>.+)$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_1LIF();

[GeneratedRegex(@"(\s|^)_$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_LINECONT();

[GeneratedRegex(@"^#pragma\s+(?<option>[a-z_]\w+)\b\s*(\((?<params>.*)\))?\s*", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_PRAGMA();

[GeneratedRegex(@"^#(end-?)?region\b", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_REGION();

[GeneratedRegex(@"^#(comments\-end|ce)(\b|$)", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_CE();

[GeneratedRegex(@"^#(comments\-start|cs)(\b|$)", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_CS();

[GeneratedRegex(@"\;[^\""\']*$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_COMMENT();

[GeneratedRegex(@"^([^\""\;]*\""[^\""]*\""[^\""\;]*)*(?<cmt>\;).*$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_COMMENT_AFTER_STRING1();

[GeneratedRegex(@"^([^'\;]*'[^']*'[^'\;]*)*(?<cmt>\;).*$", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex GenRegex_COMMENT_AFTER_STRING2();

#endregion
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/AutoItInterpreter/version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.12.2390.8650
fc8e83b32164422fe0cbcc8b641fbb42ebe0d778
0.12.2392.8652
b728be29d3366955236e5645a70fc5317b5de033

0 comments on commit 79dd353

Please sign in to comment.