Fix dotnet build, remove not used code

This commit is contained in:
Ivan Kochurkin 2020-12-28 13:51:17 +03:00
parent 22967d3ccd
commit dc8fc4f94f
5 changed files with 33 additions and 92 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<NoWarn>$(NoWarn);CS3021</NoWarn> <NoWarn>$(NoWarn);CS3021</NoWarn>
<AssemblyName>Test</AssemblyName> <AssemblyName>Test</AssemblyName>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>

View File

@ -166,40 +166,6 @@ public class BaseCSharpTest implements RuntimeTestSupport {
return antlrToolErrors.toString(); return antlrToolErrors.toString();
} }
protected org.antlr.v4.Tool newTool(String[] args) {
Tool tool = new Tool(args);
return tool;
}
protected Tool newTool() {
org.antlr.v4.Tool tool = new Tool(new String[]{"-o", tmpdir});
return tool;
}
protected String load(String fileName, String encoding)
throws IOException {
if (fileName == null) {
return null;
}
String fullFileName = getClass().getPackage().getName().replace('.', '/') + '/' + fileName;
int size = 65000;
InputStreamReader isr;
InputStream fis = getClass().getClassLoader().getResourceAsStream(fullFileName);
if (encoding != null) {
isr = new InputStreamReader(fis, encoding);
} else {
isr = new InputStreamReader(fis);
}
try {
char[] data = new char[size];
int n = isr.read(data);
return new String(data, 0, n);
} finally {
isr.close();
}
}
protected String execLexer(String grammarFileName, protected String execLexer(String grammarFileName,
String grammarStr, String grammarStr,
String lexerName, String lexerName,
@ -232,7 +198,7 @@ public class BaseCSharpTest implements RuntimeTestSupport {
return output; return output;
} }
Set<String> sourceFiles = new HashSet<String>(); Set<String> sourceFiles = new HashSet<>();
private void addSourceFiles(String... files) { private void addSourceFiles(String... files) {
for (String file : files) for (String file : files)
@ -346,12 +312,8 @@ public class BaseCSharpTest implements RuntimeTestSupport {
} }
} }
private boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}
private String locateExec() { private String locateExec() {
return new File(tmpdir, "bin/Release/netcoreapp2.0/Test.dll").getAbsolutePath(); return new File(tmpdir, "bin/Release/netcoreapp3.1/Test.dll").getAbsolutePath();
} }
public boolean buildProject() { public boolean buildProject() {

View File

@ -15,14 +15,14 @@
<Authors>Eric Vergnaud, Terence Parr, Sam Harwell</Authors> <Authors>Eric Vergnaud, Terence Parr, Sam Harwell</Authors>
<Description>The .NET Core C# ANTLR 4 runtime from the ANTLR Organization</Description> <Description>The .NET Core C# ANTLR 4 runtime from the ANTLR Organization</Description>
<Summary>The runtime library for parsers generated by the C# target of the standard ANTLR 4 tool.</Summary> <Summary>The runtime library for parsers generated by the C# target of the standard ANTLR 4 tool.</Summary>
<Copyright>Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.</Copyright> <Copyright>Copyright (c) 2012-2020 The ANTLR Project. All rights reserved.</Copyright>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseUrl>https://github.com/antlr/antlr4/blob/master/LICENSE.txt</PackageLicenseUrl> <PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/antlr/antlr4</PackageProjectUrl> <PackageProjectUrl>https://github.com/antlr/antlr4</PackageProjectUrl>
<!-- <PackageIcon>Antlr.png</PackageIcon> -->
<PackageIconUrl>https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png</PackageIconUrl> <PackageIconUrl>https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png</PackageIconUrl>
<PackageReleaseNotes>https://github.com/antlr/antlr4/releases</PackageReleaseNotes> <PackageReleaseNotes>https://github.com/antlr/antlr4/releases</PackageReleaseNotes>
<PackageTags>antlr parsing grammar</PackageTags> <PackageTags>antlr parsing grammar</PackageTags>
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute> <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute> <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@ -44,7 +44,4 @@
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>lib\Release</OutputPath> <OutputPath>lib\Release</OutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<DefineConstants>NETSTANDARD20</DefineConstants>
</PropertyGroup>
</Project> </Project>

View File

@ -174,6 +174,7 @@ namespace Antlr4.Runtime
{ {
children = new List<IParseTree>(); children = new List<IParseTree>();
} }
children.Add(t); children.Add(t);
} }
@ -183,6 +184,7 @@ namespace Antlr4.Runtime
{ {
children = new List<IParseTree>(); children = new List<IParseTree>();
} }
children.Add(ruleInvocation); children.Add(ruleInvocation);
} }
@ -236,6 +238,7 @@ namespace Antlr4.Runtime
{ {
return default(T); return default(T);
} }
int j = -1; int j = -1;
// what element have we found with ctxType? // what element have we found with ctxType?
foreach (IParseTree o in children) foreach (IParseTree o in children)
@ -249,6 +252,7 @@ namespace Antlr4.Runtime
} }
} }
} }
return default(T); return default(T);
} }
@ -258,6 +262,7 @@ namespace Antlr4.Runtime
{ {
return null; return null;
} }
int j = -1; int j = -1;
// what token with ttype have we found? // what token with ttype have we found?
foreach (IParseTree o in children) foreach (IParseTree o in children)
@ -276,15 +281,17 @@ namespace Antlr4.Runtime
} }
} }
} }
return null; return null;
} }
public virtual IReadOnlyList<ITerminalNode> GetTokens(int ttype) public virtual ITerminalNode[] GetTokens(int ttype)
{ {
if (children == null) if (children == null)
{ {
return Collections.EmptyList<ITerminalNode>(); return Collections.EmptyList<ITerminalNode>();
} }
List<ITerminalNode> tokens = null; List<ITerminalNode> tokens = null;
foreach (IParseTree o in children) foreach (IParseTree o in children)
{ {
@ -298,16 +305,18 @@ namespace Antlr4.Runtime
{ {
tokens = new List<ITerminalNode>(); tokens = new List<ITerminalNode>();
} }
tokens.Add(tnode); tokens.Add(tnode);
} }
} }
} }
if (tokens == null) if (tokens == null)
{ {
return Collections.EmptyList<ITerminalNode>(); return Collections.EmptyList<ITerminalNode>();
} }
return tokens; return tokens.ToArray();
} }
public virtual T GetRuleContext<T>(int i) public virtual T GetRuleContext<T>(int i)
@ -316,13 +325,14 @@ namespace Antlr4.Runtime
return GetChild<T>(i); return GetChild<T>(i);
} }
public virtual IReadOnlyList<T> GetRuleContexts<T>() public virtual T[] GetRuleContexts<T>()
where T : Antlr4.Runtime.ParserRuleContext where T : Antlr4.Runtime.ParserRuleContext
{ {
if (children == null) if (children == null)
{ {
return Collections.EmptyList<T>(); return Collections.EmptyList<T>();
} }
List<T> contexts = null; List<T> contexts = null;
foreach (IParseTree o in children) foreach (IParseTree o in children)
{ {
@ -332,23 +342,22 @@ namespace Antlr4.Runtime
{ {
contexts = new List<T>(); contexts = new List<T>();
} }
contexts.Add((T) o); contexts.Add((T) o);
} }
} }
if (contexts == null) if (contexts == null)
{ {
return Collections.EmptyList<T>(); return Collections.EmptyList<T>();
} }
return contexts; return contexts.ToArray();
} }
public override int ChildCount public override int ChildCount
{ {
get get { return children != null ? children.Count : 0; }
{
return children != null ? children.Count : 0;
}
} }
public override Interval SourceInterval public override Interval SourceInterval
@ -359,32 +368,21 @@ namespace Antlr4.Runtime
{ {
return Interval.Invalid; return Interval.Invalid;
} }
return Interval.Of(_start.TokenIndex, _stop.TokenIndex); return Interval.Of(_start.TokenIndex, _stop.TokenIndex);
} }
} }
public virtual IToken Start public virtual IToken Start
{ {
get get { return _start; }
{ set { _start = value; }
return _start;
}
set
{
_start = value;
}
} }
public virtual IToken Stop public virtual IToken Stop
{ {
get get { return _stop; }
{ set { _stop = value; }
return _stop;
}
set
{
_stop = value;
}
} }
/// <summary>Used for rule context info debugging during parse-time, not so much for ATN debugging</summary> /// <summary>Used for rule context info debugging during parse-time, not so much for ATN debugging</summary>

View File

@ -1,16 +0,0 @@
/* 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 NETSTANDARD20
namespace System
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate, Inherited = false)]
internal sealed class SerializableAttribute : Attribute
{
}
}
#endif