Skip to content

Commit

Permalink
Include BNF in Resources
Browse files Browse the repository at this point in the history
  • Loading branch information
TGNThump committed May 2, 2018
1 parent 945b4f6 commit a5279dd
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 13 deletions.
115 changes: 115 additions & 0 deletions GroupProjectRASQL/BNF/ra.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
[query] => [projection]
[query] => [selection]
[query] => [rename]
[query] => [join]
[query] => [setOperation]
[query] => [string]
[query] => '(' + [query] + ')'

[projection] => [pi] + ' ' + [attributeList] + ' ('+ [query] + ')'

[pi] => 'PI'
[pi] => 'PROJECT'
[pi] => 'π'

[attributeList] => [field]
[attributeList] => [field] + [comma] + [attributeList]


[selection] => [sigma] + ' ' + [condition] + ' (' + [query] + ')'

[sigma] => 'SIGMA'
[sigma] => 'σ'
[sigma] => 'SELECT'

[condition] => [literal]
[condition] => '(' + [condition] + ')'
[condition] => [andCondition]
[condition] => [orCondition]
[condition] => [notCondition]

[literal] => [value]
[literal] => [value] + [operator] + [value]
[literal] => [value] + ' ' + [operator] + ' ' + [value]
[literal] => [value] + [operator] + ' ' + [value]
[literal] => [value] + ' ' + [operator] + [value]

[andCondition] => [condition] + ' AND ' + [condition]
[orCondition] => [condition] + ' OR ' + [condition]
[notCondition] => 'NOT ' + [condition]

[rename] => [attRename]
[rename] => [relRename]

[attRename] => [rho] + ' ' + [field] + '/' + [field] + ' (' + [query] + ')'
[relRename] => [rho] + ' ' + [string] + ' (' + [query] + ')'

[rho] => 'RHO'
[rho] => 'ρ'
[rho] => 'RENAME'

[join] => [joinSymbol] + ' ' + [condition] + ' (' + [query] + [comma] + [query] + ')'
[join] => [joinSymbol] + '(' + [query] + [comma] + [query] + ')'

[joinSymbol] => 'JOIN'
[joinSymbol] => ''


[setOperation] => [union]
[setOperation] => [intersection]
[setOperation] => [cartesian]
[setOperation] => [difference]


[union] => [unionSymbol] + '(' + [query] + [comma] + [query] + ')'

[unionSymbol] => 'UNION'
[unionSymbol] => ''
[unionSymbol] => 'U'

[intersection] => [intersectSymbol] + '(' + [query] + [comma] + [query] + ')'

[intersectSymbol] => 'INTERSECT'
[intersectSymbol] => ''
[intersectSymbol] => 'N'

[cartesian] => 'X(' + [query] + [comma] + [query] + ')'
[cartesian] => 'x(' + [query] + [comma] + [query] + ')'

[difference] => '-(' + [query] + [comma] + [query] + ')'

[operator] => '='
[operator] => '<>'
[operator] => '>'
[operator] => '<'
[operator] => '<='
[operator] => '>='

[value] => [field]
[value] => [numeric]
[value] => [quote] + [string] + [quote]
[value] => [null]

[null] => 'NULL'

[int] => [0-9]
[int] => [int] + [0-9]

[numeric] => [int]
[numeric] => [int] + '.' + [int]

[quote] => '\''
[quote] => '"'

[comma] => ','
[comma] => ',' + ' '

[char] => [a-zA-Z]
[char] => [int]

[string] => [char]
[string] => [char] + [string]

[table] => [string]
[field] => [string]
[field] => [string] + '.' + [string]
75 changes: 75 additions & 0 deletions GroupProjectRASQL/BNF/sql.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[query] => [select] + ' ' + [from] + ' ' + [where] + ';'
[query] => [select] + ' ' + [from] + ';'

[select] => 'SELECT ' + [selectList]
[from] => 'FROM ' + [fromList]
[where] => 'WHERE ' + [condition]

[selectList] => '*'
[selectList] => [selectElement] + [comma] + [selectList]
[selectList] => [selectElement]

[selectElement] => [field] + ' AS ' + [string]
[selectElement] => [field]

[fromList] => [fromElement] + [comma] + [fromList]
[fromList] => [fromElement]

[fromElement] => [join]
[fromElement] => [table]
[fromElement] => [fromElement] + ' AS ' + [table]
[fromElement] => '(' + [query] + ') ' + [table]

[join] => [fromElement] + ' JOIN ' + [fromElement] + ' ON ' + [condition]

[condition] => [literal]
[condition] => '(' + [condition] + ')'
[condition] => [andCondition]
[condition] => [orCondition]
[condition] => [notCondition]

[literal] => [value]
[literal] => [value] + [operator] + [value]
[literal] => [value] + ' ' + [operator] + ' ' + [value]
[literal] => [value] + [operator] + ' ' + [value]
[literal] => [value] + ' ' + [operator] + [value]

[andCondition] => [condition] + ' AND ' + [condition]
[orCondition] => [condition] + ' OR ' + [condition]
[notCondition] => 'NOT ' + [condition]

[operator] => '='
[operator] => '<>'
[operator] => '>'
[operator] => '<'
[operator] => '<='
[operator] => '>='

[value] => [field]
[value] => [numeric]
[value] => [quote] + [string] + [quote]
[value] => [null]

[null] => 'NULL'

[int] => [0-9]
[int] => [int] + [0-9]

[numeric] => [int]
[numeric] => [int] + '.' + [int]

[quote] => '\''
[quote] => '"'

[comma] => ','
[comma] => ',' + ' '

[char] => [a-zA-Z]
[char] => [int]

[string] => [char]
[string] => [char] + [string]

[table] => [string]
[field] => [string]
[field] => [string] + '.' + [string]
29 changes: 24 additions & 5 deletions GroupProjectRASQL/GroupProjectRASQL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<WarningLevel>4</WarningLevel>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>C:\Users\ben\Desktop\COMP208BUILD\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
Expand All @@ -28,10 +29,10 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand All @@ -58,6 +59,18 @@
<PropertyGroup>
<StartupObject>GroupProjectRASQL.App</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>8B9494DAF33EF62C2A6C9465009F5D13AFEE6701</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>GroupProjectRASQL_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="MoreCollection, Version=1.2.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MoreCollection.1.2.2\lib\net45\MoreCollection.dll</HintPath>
Expand All @@ -74,8 +87,9 @@
<Reference Include="Neutronium.WPF, Version=1.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Neutronium.WPF.1.3.1\lib\Neutronium.WPF.dll</HintPath>
</Reference>
<Reference Include="PropertyChanged, Version=2.5.2.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
<HintPath>..\packages\PropertyChanged.Fody.2.5.2\lib\netstandard1.0\PropertyChanged.dll</HintPath>
<Reference Include="PropertyChanged">
<HintPath>..\packages\PropertyChanged.Fody.2.5.4\lib\netstandard1.0\PropertyChanged.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
Expand Down Expand Up @@ -166,6 +180,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="BNF\ra.lua" />
<EmbeddedResource Include="BNF\sql.lua" />
<None Include="GroupProjectRASQL_TemporaryKey.pfx" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
Expand Down Expand Up @@ -229,6 +246,7 @@
<Error Condition="!Exists('..\packages\Neutronium.WebBrowserEngine.ChromiumFx.1.3.1\build\Neutronium.WebBrowserEngine.ChromiumFx.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Neutronium.WebBrowserEngine.ChromiumFx.1.3.1\build\Neutronium.WebBrowserEngine.ChromiumFx.props'))" />
<Error Condition="!Exists('..\packages\Neutronium.WebBrowserEngine.ChromiumFx.1.3.1\build\Neutronium.WebBrowserEngine.ChromiumFx.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Neutronium.WebBrowserEngine.ChromiumFx.1.3.1\build\Neutronium.WebBrowserEngine.ChromiumFx.targets'))" />
<Error Condition="!Exists('..\packages\Fody.3.0.3\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.0.3\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.2.0.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.2.0.0\build\Costura.Fody.targets'))" />
</Target>
<Import Project="..\packages\Unofficial.Cef.for.Chromiumfx.x64.3.2924.1\build\Unofficial.Cef.for.Chromiumfx.x64.targets" Condition="Exists('..\packages\Unofficial.Cef.for.Chromiumfx.x64.3.2924.1\build\Unofficial.Cef.for.Chromiumfx.x64.targets')" />
<Import Project="..\packages\Unofficial.Cef.for.Chromiumfx.x86.3.2924.1\build\Unofficial.Cef.for.Chromiumfx.x86.targets" Condition="Exists('..\packages\Unofficial.Cef.for.Chromiumfx.x86.3.2924.1\build\Unofficial.Cef.for.Chromiumfx.x86.targets')" />
Expand All @@ -238,6 +256,7 @@
</PropertyGroup>
<Import Project="..\packages\Neutronium.WebBrowserEngine.ChromiumFx.1.3.1\build\Neutronium.WebBrowserEngine.ChromiumFx.targets" Condition="Exists('..\packages\Neutronium.WebBrowserEngine.ChromiumFx.1.3.1\build\Neutronium.WebBrowserEngine.ChromiumFx.targets')" />
<Import Project="..\packages\Fody.3.0.3\build\Fody.targets" Condition="Exists('..\packages\Fody.3.0.3\build\Fody.targets')" />
<Import Project="..\packages\Costura.Fody.2.0.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.2.0.0\build\Costura.Fody.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
2 changes: 1 addition & 1 deletion GroupProjectRASQL/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
mc:Ignorable="d"
Name="Root"
Visibility="{Binding ElementName=HtmlView, Path=IsHTMLLoaded, Converter={StaticResource BooleanToVisibilityConverter}}"
Height="350" Width="525">
Height="480" Width="720">
<Grid>

<WPF:HTMLViewControl x:Name="HtmlView" IsDebug="{Binding ElementName=Root, Path=Debug}" Uri="{Binding ElementName=Root, Path=Uri}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
Expand Down
14 changes: 11 additions & 3 deletions GroupProjectRASQL/Parser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Text;
using System.Threading.Tasks;
using Truncon.Collections;
using System.IO;
using System.Reflection;

namespace GroupProjectRASQL.Parser
{
Expand Down Expand Up @@ -56,9 +58,15 @@ class Parser
//Create a parser for a given grammar
public Parser(String type = "sql")
{
//Get the path to the grammar file, then get contents of file
String path = @"..\..\..\bnf\" + type + ".lua";
String[] lines = System.IO.File.ReadAllLines(path);
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "GroupProjectRASQL.BNF." + type + ".lua";

String[] lines;
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
lines = reader.ReadToEnd().Split('\n');
}

//For each line in the file, add the rules to the grammar
for(int i=0; i<lines.Length; i++)
Expand Down
2 changes: 1 addition & 1 deletion GroupProjectRASQL/View/dist/build.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion GroupProjectRASQL/View/dist/build.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions GroupProjectRASQL/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="2.0.0" targetFramework="net45" />
<package id="Fody" version="3.0.3" targetFramework="net45" developmentDependency="true" />
<package id="Microsoft.NETCore.Platforms" version="2.0.1" targetFramework="net45" />
<package id="Microsoft.NETCore.Platforms" version="2.0.2" targetFramework="net45" />
<package id="MoreCollection" version="1.2.2" targetFramework="net45" />
<package id="NETStandard.Library" version="2.0.2" targetFramework="net45" />
<package id="Neutronium.ChromiumFx.Vue" version="1.3.1" targetFramework="net45" />
Expand All @@ -10,7 +11,7 @@
<package id="Neutronium.MVVMComponents" version="1.2.0" targetFramework="net45" />
<package id="Neutronium.WebBrowserEngine.ChromiumFx" version="1.3.1" targetFramework="net45" />
<package id="Neutronium.WPF" version="1.3.1" targetFramework="net45" />
<package id="PropertyChanged.Fody" version="2.5.2" targetFramework="net45" />
<package id="PropertyChanged.Fody" version="2.5.4" targetFramework="net45" />
<package id="System.Collections" version="4.3.0" targetFramework="net45" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net45" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net45" />
Expand Down

0 comments on commit a5279dd

Please sign in to comment.