Add initial string parsing system.
This commit is contained in:
parent
945ec83feb
commit
ecbc2f217f
3 changed files with 39 additions and 1 deletions
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace cscz
|
||||
{
|
||||
|
@ -39,6 +41,29 @@ namespace cscz
|
|||
{
|
||||
}
|
||||
|
||||
public void ParseString(string source)
|
||||
{
|
||||
StringReader lines = new StringReader(source);
|
||||
|
||||
string nextLine = string.Empty;
|
||||
do {
|
||||
nextLine = lines.ReadLine();
|
||||
|
||||
if(nextLine == null) break;
|
||||
|
||||
// It's a using statement
|
||||
if(nextLine.StartsWith("u "))
|
||||
{
|
||||
string[] parts = Regex.Split(nextLine.Trim(), @"\s+");
|
||||
UsingStatements.Add(parts[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Signatures.Add(nextLine.Trim());
|
||||
}
|
||||
} while(nextLine != null);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
@ -95,7 +120,6 @@ namespace cscz
|
|||
|
||||
// Close the class off and end the file
|
||||
result.AppendLine("}");
|
||||
result.AppendLine();
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace cscz
|
||||
{
|
||||
|
@ -7,9 +9,16 @@ namespace cscz
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
ClassGenerator cg = new ClassGenerator();
|
||||
/*
|
||||
cg.Signatures.Add("float radius");
|
||||
cg.Signatures.Add("double weight");
|
||||
Console.WriteLine(cg);
|
||||
*/
|
||||
|
||||
string source = Console.In.ReadToEnd();
|
||||
cg.ParseString(source);
|
||||
|
||||
Console.WriteLine(cg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CustomCommands>
|
||||
<CustomCommands>
|
||||
<Command type="Execute" command="cat Carrot.cscz | ./cscz" workingdir="${TargetDir}" externalConsole="True" pauseExternalConsole="True" />
|
||||
</CustomCommands>
|
||||
</CustomCommands>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>full</DebugType>
|
||||
|
|
Loading…
Reference in a new issue