Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/CosmosOS/XSharp
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbetros committed Aug 13, 2017
2 parents 43ca62c + 65f512b commit 18576fe
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 48 deletions.
12 changes: 0 additions & 12 deletions ToDos.txt
Expand Up @@ -2,18 +2,6 @@ Kudzu ----------------------------------------------------

Clogger
-Change XSC to use

Base CLI, just options and others
-switches - inherit and have public props
-files etc.
-if not file, put in other
-log index in array, and also a list of all to find next, previous, etc... also have a next,previous pointer
-flags -name:value
Reusable command line arg parser
in build
-values allowed for options, etc... use Enums and types? or simple key values, or comment and evolve.. can use in zConsole later


/! directives
-namespace too
pre/post directives, separate api than normal pre/post
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Expand Up @@ -17,9 +17,10 @@ nuget:
build_script:
- cmd: |
nuget restore "XSharp.sln"
msbuild "XSharp.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug /p:DeployExtension=false
msbuild "XSharp.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug /p:VersionSuffix="%APPVEYOR_BUILD_NUMBER%" /p:DeployExtension=false
dotnet pack "source\XSharp.Assembler" -c Release --version-suffix %APPVEYOR_BUILD_NUMBER%
dotnet pack "source\XSharp.Build" -c Release --version-suffix %APPVEYOR_BUILD_NUMBER%
dotnet pack "source\XSharp" -c Release --version-suffix %APPVEYOR_BUILD_NUMBER%
dotnet pack "source\XSharp.DotNetCLI" -c Release --version-suffix %APPVEYOR_BUILD_NUMBER%
Expand Down
2 changes: 1 addition & 1 deletion playground/CmdProcess.asm
@@ -1,4 +1,4 @@
; Generated at 8/12/2017 6:50:14 PM
; Generated at 8/13/2017 12:01:44 PM



Expand Down
45 changes: 25 additions & 20 deletions source/XSharp.Build/CliProcessor.cs
Expand Up @@ -5,36 +5,41 @@
namespace XSharp.Build {
public class CliProcessor {
public class Item {
public readonly int OrigIdx = -1;
public readonly string Value;
public readonly Item Previous;
public readonly Item Next;

public Item(int aIdx, string aValue, Item aPrev, Item aNext) {
OrigIdx = aIdx;
Value = aValue;
Previous = aPrev;
Next = aNext;
}
public string Value;
public Switch Switch;
}

public class Switch : Item {
public readonly string Name;

public Switch(int aIdx, string aName, string aValue, Item aPrev, Item aNext) : base(aIdx, aValue, aPrev, aNext) {
Name = aName;
}
public class Switch {
public string Name;
public string Value;
}

public List<Item> All = new List<Item>();
public List<Item> Files = new List<Item>();
public List<Item> Others = new List<Item>();
public List<Item> Items = new List<Item>();
// Do not use dictionary. Dictionary loses order and dose not allow multiples.
public List<Switch> Switches = new List<Switch>();

public CliProcessor(string[] aArgs, bool aAllowNone = false) {
if (aAllowNone == false && aArgs.Length == 0) {
throw new Exception("No arguments were specified.");
}

Switch xSwitch = null;
foreach (var xArg in aArgs) {
if (xArg.StartsWith("-")) {
xSwitch = new Switch();
var xParts = xArg.Substring(1).ToUpper().Split(':');
xSwitch.Name = xParts[0];
if (xParts.Length > 1) {
xSwitch.Value = xParts[1];
}
Switches.Add(xSwitch);
} else {
var xItem = new Item();
xItem.Value = xArg;
xItem.Switch = xSwitch;
Items.Add(xItem);
}
}
}
}
}
2 changes: 2 additions & 0 deletions source/XSharp.Build/XSharp.Build.csproj
Expand Up @@ -2,6 +2,8 @@

<PropertyGroup>
<TargetFramework>netstandard1.5</TargetFramework>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\XSharp.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
23 changes: 9 additions & 14 deletions source/XSharp.DotNetCLI/Program.cs
Expand Up @@ -7,28 +7,23 @@ namespace XSharp.DotNetCLI {
class Program {
static void Main(string[] aArgs) {
try {
var xCLI = new XSharp.Build.CliProcessor(aArgs);
var xGen = new AsmGenerator();
var xFiles = new List<string>();

// Parse arguments
foreach (var xArg in aArgs) {
if (xArg.StartsWith("-")) {
string xOpt = xArg.Substring(1).ToUpper();
throw new Exception("No matching switch found: " + xArg);
var xCLI = new XSharp.Build.CliProcessor(aArgs);
foreach (var xArg in xCLI.Items) {
if (Directory.Exists(xArg.Value)) {
string xPath = Path.GetFullPath(xArg.Value);
xFiles.AddRange(Directory.GetFiles(xPath, "*.xs"));
} else if (File.Exists(xArg.Value)) {
xFiles.Add(Path.GetFullPath(xArg.Value));
} else {
if (Directory.Exists(xArg)) {
string xPath = Path.GetFullPath(xArg);
xFiles.AddRange(Directory.GetFiles(xPath, "*.xs"));
} else if (File.Exists(xArg)) {
xFiles.Add(Path.GetFullPath(xArg));
} else {
throw new Exception("Not a valid file or directory: " + xArg);
}
throw new Exception("Not a valid file or directory: " + xArg);
}
}

// Generate output
var xGen = new AsmGenerator();
foreach (var xFile in xFiles) {
Console.WriteLine(xFile);
xGen.GenerateToFiles(xFile);
Expand Down
6 changes: 6 additions & 0 deletions source/XSharp/AsmGenerator.cs
Expand Up @@ -10,8 +10,14 @@ namespace XSharp {
public class AsmGenerator {
protected TokenPatterns mPatterns = new TokenPatterns();

public enum FlagBool {
On, Off, Inherit
}
/// <summary>Should we keep the user comments in the generated target assembly program ?</summary>
public bool EmitUserComments = false;

public bool EmitSourceCode = true;

protected int mLineNo = 0;
protected string mPathname = "";

Expand Down

0 comments on commit 18576fe

Please sign in to comment.