AJ
AJ
CC#
Created by AJ on 10/30/2023 in #help
❔ Trying to run a command through C# on macOS
I'm currently utilising Jetbrains rider. My tutor has tasked me with creating a simple little C# transpiler, that will have source code, which works and builds into a CS file, after that it then needs to compile via Mono. Everything works except trying to get the csc build.cs file working.
void Build()
{
...
Compile($"csc {buildDir}/build.cs");
}

void Compile(string command)
{
Process.Start("csc", command);
Environment.Exit(0);
}
void Build()
{
...
Compile($"csc {buildDir}/build.cs");
}

void Compile(string command)
{
Process.Start("csc", command);
Environment.Exit(0);
}
12 replies
CC#
Created by AJ on 10/13/2023 in #help
❔ System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
I've been programming for a handful of years, but never to a level of complexity i've been comfortable with in C#, however now in university me and a friend have been taked with creating a small little programming language transpiler as a side project by our tutor. It's a simple Console application which can read information and then will (not complete yet) dump it into a C# file. Somehow I managed to do this in python before, but C# is giving me some headache. Code:
using System;
using System.IO;
using System.Collections.Generic;
internal class Program
{
public static void Main(string[] args)
{
// Create a string array for all items due to be compiled
List<string> ghouLines = new List<string>();
string buildDirectory = Directory.GetCurrentDirectory(); // Build directory
while (true) {
string input = Console.ReadLine();
// Variables
if (input.Substring(0,3) == "mut") {
int equals = input.IndexOf('=') - 1;
string variableName = input.Substring(3,equals);
int endArg = input.IndexOf(';');
string variableData = input.Substring(equals,endArg);
ghouLines.Add($"var {variableName} {variableData};");
}
ghouLines.ForEach(i => Console.Write("{0}\t", i)); // DEBUG
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
internal class Program
{
public static void Main(string[] args)
{
// Create a string array for all items due to be compiled
List<string> ghouLines = new List<string>();
string buildDirectory = Directory.GetCurrentDirectory(); // Build directory
while (true) {
string input = Console.ReadLine();
// Variables
if (input.Substring(0,3) == "mut") {
int equals = input.IndexOf('=') - 1;
string variableName = input.Substring(3,equals);
int endArg = input.IndexOf(';');
string variableData = input.Substring(equals,endArg);
ghouLines.Add($"var {variableName} {variableData};");
}
ghouLines.ForEach(i => Console.Write("{0}\t", i)); // DEBUG
}
}
}
Input:
mut a = 3;
mut a = 3;
70 replies