Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamQiufeng committed Aug 25, 2022
1 parent cbe308f commit a6c4cde
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 31 deletions.
1 change: 1 addition & 0 deletions PseudoCode.Core/Parsing/PseudoCodeCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public override void ExitConstantStatement(PseudoCodeParser.ConstantStatementCon

public Definition[] GetArgumentDeclarations(PseudoCodeParser.ArgumentsDeclarationContext context)
{
if (context?.argumentDeclaration() == null) return Array.Empty<Definition>();
return context.argumentDeclaration().Select(declarationContext =>
new Definition(CurrentScope, Program)
{
Expand Down
2 changes: 1 addition & 1 deletion PseudoCode.Core/run.pseudo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CONSTANT CONST = 498 + 35
iptr <- ^Char
OUTPUT CONST + 4
OUTPUT CONST + 5
OUTPUT "Right: " & RIGHT("ABCDEFGH", 3) & " " & MID("ABCDEFGH", 2, 3)
OUTPUT "Right: " & LEFT("ABCDEFGH", 3) & " " & MID("ABCDEFGH", 2, 3)
FOR ri <- 1 TO 10
OUTPUT "The " & ri & "th random number [1..10]: " & RAND(10)
NEXT ri
Expand Down
2 changes: 1 addition & 1 deletion PseudoCode.LSP/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static async Task MainAsync(string[] args)

Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.File("/Users/mac/Documents/VSCProjects/vscode-testextension/log.txt", rollingInterval: RollingInterval.Day)
.WriteTo.File("log.txt", rollingInterval: RollingInterval.Day)
.MinimumLevel.Verbose()
.CreateLogger();

Expand Down
57 changes: 30 additions & 27 deletions PseudoCode.Update/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,32 @@ public class Program
};

public const string PackageName = "PseudoCodePackage.pkg";
public const string VsixName = "caie-pseudocode.vsix";
public const string VsixName = "williamqiufeng.caie-pseudocode";

public static async Task<bool> DownloadAssetAsync(ReleaseObject obj, string s)
public static async Task<bool> DownloadAssetAsync(IEnumerable<ReleaseObject> objs, string s)
{
var obj = objs.FirstOrDefault(o => o.Assets.Any(a => a.Name == s));
if (obj == null)
{
return false;
}

var latestVersion = Version.Parse(obj.TagName);
Console.WriteLine($"Current version of {s} is {PseudoProgram.Version}, Latest version is {latestVersion}");
if (latestVersion <= PseudoProgram.Version)
{
Console.WriteLine("Current version is already the latest!");
return false;
}

var asset = obj.Assets.FirstOrDefault(a => a.Name == s);
if (asset == null)
{
Console.WriteLine($"{s} not found!");
// Environment.Exit(-1);
return false;
}

Console.WriteLine($"Downloading from url \"{asset.BrowserDownloadUrl}\"");
var response = await HttpClient.GetStreamAsync(asset.BrowserDownloadUrl);
await response.CopyToAsync(File.Create(s));
Expand All @@ -42,18 +56,12 @@ public static async Task Main()
{
var resultStr =
await HttpClient.GetStringAsync(
"https://gitee.com/api/v5/repos/williamcraft/pseudocode-releases/releases/latest");
"https://gitee.com/api/v5/repos/williamcraft/pseudocode-releases/releases?page=1&per_page=20&direction=desc");
Console.WriteLine(resultStr);
var resultObj = JsonSerializer.Deserialize<ReleaseObject>(new JsonTextReader(new StringReader(resultStr)));
var latestVersion = Version.Parse(resultObj.TagName);
Console.WriteLine($"Current version is {PseudoProgram.Version}, Latest version is {latestVersion}");
if (latestVersion <= PseudoProgram.Version)
{
Console.WriteLine("Current version is already the latest!");
Environment.Exit(0);
}
var resultObjs = JsonSerializer.Deserialize<ReleaseObject[]>(new JsonTextReader(new StringReader(resultStr)));

if (await DownloadAssetAsync(resultObj, PackageName))

if (await DownloadAssetAsync(resultObjs, PackageName))
{
var p = new Process
{
Expand All @@ -67,24 +75,19 @@ await HttpClient.GetStringAsync(
p.Start();
await p.WaitForExitAsync();
}

if (await DownloadAssetAsync(resultObj, VsixName))
var vsixProcess = new Process
{
var p = new Process
StartInfo = new ProcessStartInfo
{
StartInfo = new ProcessStartInfo
{
FileName = "code",
WorkingDirectory = Environment.CurrentDirectory,
Arguments = $"--install-extension {VsixName}"
}
};
p.Start();
await p.WaitForExitAsync();
}
FileName = "code",
WorkingDirectory = Environment.CurrentDirectory,
Arguments = $"--install-extension {VsixName}"
}
};
vsixProcess.Start();
await vsixProcess.WaitForExitAsync();



Console.WriteLine("Process ended");
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ PseudoCode -SvcC run.pseudo
- [x] Function / Procedure
- [x] Case
- [x] Struct
- [ ] Enum
- [ ] Pointer
- [x] Enum
- [x] Pointer
- [ ] Class
- [x] Built-in functions

Expand Down

0 comments on commit a6c4cde

Please sign in to comment.