Skip to content

Commit

Permalink
Fix array editor disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jaquadro committed Mar 31, 2014
1 parent e1096e2 commit 3e6240d
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 9 deletions.
2 changes: 1 addition & 1 deletion NBTExplorer.Installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Product Id="*"
Name="NBTExplorer"
Language="1033"
Version="2.7.1.0"
Version="2.7.2.0"
Manufacturer="Justin Aquadro"
UpgradeCode="0bfb1026-21f2-4552-ad71-ca90aae10a25">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
Expand Down
5 changes: 2 additions & 3 deletions NBTExplorer/NBTExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Substrate, Version=1.3.8.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\Substrate.dll</HintPath>
<Reference Include="Substrate">
<HintPath>..\References\Substrate.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down
4 changes: 2 additions & 2 deletions NBTExplorer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.7.1.0")]
[assembly: AssemblyFileVersion("2.7.1.0")]
[assembly: AssemblyVersion("2.7.2.0")]
[assembly: AssemblyFileVersion("2.7.2.0")]
101 changes: 101 additions & 0 deletions NBTModel/FilterExpressionParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NBTExplorer.Model
{
class FilterExpressionParser
{
private Stack<string> argStack = new Stack<string>();

/*public bool Parse (DataNode targetNode, List<string> tokens)
{
Queue<string> tokenQueue = new Queue<string>(FilterExpressionConverter.Convert(tokens));
while (tokenQueue.Count > 0) {
string token = tokenQueue.Dequeue();
switch (token) {
case "equal":
}
}
}*/
}

static class FilterExpressionConverter
{
private static List<List<string>> OperatorGroups = new List<List<string>> {
new List<string> { "equal", "greater", "less", "contains", "begins", "ends" },
new List<string> { "not" },
new List<string> { "and", "or" },
};

public static List<string> Convert (List<string> tokens)
{
Queue<string> tokenQueue = new Queue<string>(tokens);
List<string> output = new List<string>();
Stack<string> opStack = new Stack<string>();

while (tokenQueue.Count > 0) {
string token = tokenQueue.Dequeue();

if (IsGroupStart(token)) {
opStack.Push(token);
}
else if (IsGroupEnd(token)) {
while (opStack.Count > 0 && !IsGroupStart(opStack.Peek()))
output.Add(opStack.Pop());
if (opStack.Count == 0)
throw new Exception("Mismatched grouping");
opStack.Pop();
}
else if (IsOperator(token)) {
while (opStack.Count > 0 && IsOperator(opStack.Peek())) {
if (Precedence(token) > Precedence(opStack.Peek()))
output.Add(opStack.Pop());
}
opStack.Push(token);
}
else {
output.Add(token);
}
}

while (opStack.Count > 0) {
if (IsGroupStart(opStack.Peek()))
throw new Exception("Mismatched grouping");
output.Add(opStack.Pop());
}

return output;
}

private static bool IsGroupStart (string token)
{
return token == "(";
}

private static bool IsGroupEnd (string token)
{
return token == ")";
}

private static bool IsOperator (string token)
{
foreach (var group in OperatorGroups) {
if (group.Contains(token))
return true;
}
return false;
}

private static int Precedence (string op) {
for (int i = 0; i < OperatorGroups.Count; i++) {
if (OperatorGroups[i].Contains(op))
return i;
}
return int.MaxValue;
}
}
}
5 changes: 3 additions & 2 deletions NBTModel/NBTModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand All @@ -46,6 +46,7 @@
<Compile Include="Data\DataNodeCollection.cs" />
<Compile Include="Data\Nodes\DirectoryDataNode.cs" />
<Compile Include="Data\FileTypeRegistry.cs" />
<Compile Include="FilterExpressionParser.cs" />
<Compile Include="Interop\FormRegistry.cs" />
<Compile Include="Interop\NbtClipboardController.cs" />
<Compile Include="Interop\NbtClipboardData.cs" />
Expand Down
2 changes: 1 addition & 1 deletion NBTModel/NbtPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private IEnumerable<DataNode> EnumerateNodes (DataNode containerNode, List<strin

string part = nextLevels[0];
List<string> remainingLevels = nextLevels.GetRange(1, nextLevels.Count - 1);

if (part == "*") {
foreach (DataNode childNode in containerNode.Nodes) {
foreach (DataNode grandChildNode in EnumerateNodes(childNode, remainingLevels))
Expand Down

0 comments on commit 3e6240d

Please sign in to comment.