Skip to content

Commit

Permalink
[Internal] Parser: Adds Antlr Dependancy (#1691)
Browse files Browse the repository at this point in the history
* turned back on parser

* adding ANTLR files

* got it to build

* revert csproj

* revert

* revert

* added Component Detection

* adding notice file

* added component name

* updated cs proj

Co-authored-by: Samer Boshra <[email protected]>
  • Loading branch information
bchong95 and sboshra authored Sep 23, 2020
1 parent eb12cfe commit 5f7dd88
Show file tree
Hide file tree
Showing 195 changed files with 33,430 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Microsoft.Azure.Cosmos/src/Microsoft.Azure.Cosmos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
<Compile Remove="RuntimePerfCounters.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\ThirdPartyNotice.txt" Link="ThirdPartyNotice.txt" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Batch\HybridRowBatchSchemas.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
Expand Down Expand Up @@ -85,7 +89,6 @@
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="Antlr4.Runtime.Standard" Version="4.8.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.0.102" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
Expand Down
5 changes: 5 additions & 0 deletions Microsoft.Azure.Cosmos/src/OSS/AddStyleCopIgnoreToFile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$a = Get-Content $args[0]
$b = "// This file isn't generated, but this comment is necessary to exclude it from StyleCop analysis."
$c = "// <auto-generated/>"
$d = ""
Set-Content $args[0] -value $b, $c, $d, $a
97 changes: 97 additions & 0 deletions Microsoft.Azure.Cosmos/src/OSS/Antlr/AntlrFileStream.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// This file isn't generated, but this comment is necessary to exclude it from StyleCop analysis.
// <auto-generated/>

/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/

#if !PORTABLE

using Antlr4.Runtime.Sharpen;
using Encoding = System.Text.Encoding;
using File = System.IO.File;

namespace Antlr4.Runtime
{
#if COMPACT
using StreamReader = System.IO.StreamReader;
#endif

/// <summary>
/// This is an
/// <see cref="AntlrInputStream"/>
/// that is loaded from a file all at once
/// when you construct the object.
/// </summary>
internal class AntlrFileStream : AntlrInputStream
{
protected internal string fileName;

/// <exception cref="System.IO.IOException"/>
public AntlrFileStream(string fileName)
: this(fileName, null)
{
}

/// <exception cref="System.IO.IOException"/>
public AntlrFileStream(string fileName, Encoding encoding)
{
this.fileName = fileName;
Load(fileName, encoding);
}

/// <exception cref="System.IO.IOException"/>
public virtual void Load(string fileName, Encoding encoding)
{
if (fileName == null)
{
return;
}

string text;
#if !COMPACT
if (encoding != null)
text = File.ReadAllText(fileName, encoding);
else
text = File.ReadAllText(fileName);
#else
if (encoding != null)
text = ReadAllText(fileName, encoding);
else
text = ReadAllText(fileName);
#endif

data = text.ToCharArray();
n = data.Length;
}

public override string SourceName
{
get
{
return fileName;
}
}

#if COMPACT
private static string ReadAllText(string path)
{
using (var reader = new StreamReader(path))
{
return reader.ReadToEnd();
}
}

private static string ReadAllText(string path, Encoding encoding)
{
using (var reader = new StreamReader(path, encoding ?? Encoding.Default))
{
return reader.ReadToEnd();
}
}
#endif
}
}

#endif
Loading

0 comments on commit 5f7dd88

Please sign in to comment.