forked from jasder/antlr
Merge branch 'lecode-official-master'
This commit is contained in:
commit
c3785ce89d
|
@ -31,6 +31,9 @@ __pycache__/
|
|||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
*.user
|
||||
.vs/
|
||||
project.lock.json
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
|
|
|
@ -45,6 +45,10 @@ matrix:
|
|||
- os: linux
|
||||
jdk: oraclejdk7
|
||||
env: TARGET=csharp
|
||||
- os: linux
|
||||
jdk: oraclejdk7
|
||||
dist: trusty
|
||||
env: TARGET=dotnet
|
||||
- os: linux
|
||||
jdk: oraclejdk7
|
||||
env: TARGET=python2
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# install dotnet
|
||||
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
|
||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
|
||||
sudo apt-get update
|
||||
|
||||
sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177
|
||||
|
||||
# install mvn
|
||||
wget http://apache.mirrors.lucidnetworks.net/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz && \
|
||||
wget https://www.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz.md5 && \
|
||||
echo "$(cat apache-maven-3.3.9-bin.tar.gz.md5) apache-maven-3.3.9-bin.tar.gz" > apache-maven-3.3.9-bin.tar.gz.md5 && \
|
||||
md5sum -c *.md5
|
||||
|
||||
sudo rm -rf /usr/local/maven/ && sudo mkdir -p /usr/local/maven && \
|
||||
sudo tar xzvf apache-maven-3.3.9-bin.tar.gz -C /usr/local/maven --strip-components=1
|
||||
|
||||
mvn -v
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=csharp.* -DargLine="-Dantlr-csharp-netstandard=true" test
|
||||
|
|
@ -133,4 +133,6 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2017/01/13, marcelo-rocha, Marcelo Rocha, mcrocha@gmail.com
|
||||
2017/01/23, bhamiltoncx, Ben Hamilton, bhamiltoncx+antlr@gmail.com
|
||||
2017/01/18, mshockwave, Bekket McClane, yihshyng223@gmail.com
|
||||
2017/02/10, lionelplessis, Lionel Plessis, lionelplessis@users.noreply.github.com
|
||||
2017/02/10, lionelplessis, Lionel Plessis, lionelplessis@users.noreply.github.com
|
||||
2017/02/14, lecode-official, David Neumann, david.neumann@lecode.de
|
||||
2017/02/14, xied75, Dong Xie, xied75@gmail.com
|
|
@ -10,7 +10,6 @@ import org.antlr.v4.runtime.CommonTokenStream;
|
|||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenSource;
|
||||
import org.antlr.v4.runtime.WritableToken;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
import org.antlr.v4.test.runtime.ErrorQueue;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestSupport;
|
||||
import org.antlr.v4.test.runtime.StreamVacuum;
|
||||
|
@ -60,6 +59,12 @@ public class BaseCSharpTest implements RuntimeTestSupport /*, SpecialRuntimeTest
|
|||
public static final String newline = System.getProperty("line.separator");
|
||||
public static final String pathSep = System.getProperty("path.separator");
|
||||
|
||||
/**
|
||||
* When {@code true}, on Linux will call dotnet cli toolchain, otherwise
|
||||
* will continue to use mono
|
||||
*/
|
||||
public static final boolean NETSTANDARD = Boolean.parseBoolean(System.getProperty("antlr-csharp-netstandard"));
|
||||
|
||||
/**
|
||||
* When the {@code antlr.preserve-test-dir} runtime property is set to
|
||||
* {@code true}, the temporary directories created by the test run will not
|
||||
|
@ -354,15 +359,25 @@ public class BaseCSharpTest implements RuntimeTestSupport /*, SpecialRuntimeTest
|
|||
}
|
||||
|
||||
public boolean compile() {
|
||||
try {
|
||||
if(!createProject())
|
||||
return false;
|
||||
if(!buildProject())
|
||||
return false;
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
if(!NETSTANDARD) {
|
||||
try {
|
||||
if(!createProject())
|
||||
return false;
|
||||
if(!buildProject())
|
||||
return false;
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
return createDotnetProject() && buildDotnetProject();
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private File getTestProjectFile() {
|
||||
|
@ -408,7 +423,10 @@ public class BaseCSharpTest implements RuntimeTestSupport /*, SpecialRuntimeTest
|
|||
}
|
||||
|
||||
private String locateExec() {
|
||||
return new File(tmpdir, "bin/Release/Test.exe").getAbsolutePath();
|
||||
if (!NETSTANDARD)
|
||||
return new File(tmpdir, "bin/Release/Test.exe").getAbsolutePath();
|
||||
|
||||
return new File(tmpdir, "src/bin/Debug/netcoreapp1.0/Test.dll").getAbsolutePath();
|
||||
}
|
||||
|
||||
private String locateTool(String tool) {
|
||||
|
@ -475,6 +493,105 @@ public class BaseCSharpTest implements RuntimeTestSupport /*, SpecialRuntimeTest
|
|||
}
|
||||
}
|
||||
|
||||
public boolean createDotnetProject() {
|
||||
try {
|
||||
mkdir(tmpdir + "/src");
|
||||
|
||||
// move files to /src, since global.json need to be one level higher
|
||||
File source = new File(tmpdir);
|
||||
File[] files = source.listFiles();
|
||||
for (File thisSource : files) {
|
||||
if (!thisSource.isDirectory()) {
|
||||
File thisDest = new File(tmpdir + "/src/" + thisSource.getName());
|
||||
boolean success = thisSource.renameTo(thisDest);
|
||||
|
||||
if (!success) {
|
||||
throw new RuntimeException("Moving file " + thisSource + " to " + thisDest + " failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save auxiliary files
|
||||
String pack = BaseCSharpTest.class.getPackage().getName().replace(".", "/") + "/";
|
||||
saveResourceAsFile(pack + "global.json", new File(tmpdir, "global.json"));
|
||||
saveResourceAsFile(pack + "project.json", new File(tmpdir, "src/project.json"));
|
||||
return true;
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean buildDotnetProject() {
|
||||
// find runtime package
|
||||
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
final URL runtimeProj = loader.getResource("CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.xproj");
|
||||
if ( runtimeProj==null ) {
|
||||
throw new RuntimeException("C# runtime project file not found!");
|
||||
}
|
||||
File runtimeProjFile = new File(runtimeProj.getFile());
|
||||
String runtimeProjPath = runtimeProjFile.getParentFile().getParentFile().getPath();
|
||||
String projectRefPath = runtimeProjPath.substring(0, runtimeProjPath.lastIndexOf("/"));
|
||||
|
||||
// update global.json to reference runtime path
|
||||
try {
|
||||
String content = new java.util.Scanner(new File(tmpdir + "/global.json")).useDelimiter("\\Z").next();
|
||||
content = content.replaceAll("replace_this", projectRefPath);
|
||||
java.io.PrintWriter out = new java.io.PrintWriter(tmpdir + "/global.json");
|
||||
out.write(content);
|
||||
out.close();
|
||||
}
|
||||
catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// build test
|
||||
String dotnetcli = locateTool("dotnet");
|
||||
String[] args = new String[] {
|
||||
dotnetcli,
|
||||
"restore",
|
||||
".",
|
||||
projectRefPath
|
||||
};
|
||||
|
||||
try {
|
||||
boolean success = runProcess(args, tmpdir);
|
||||
|
||||
args = new String[] {
|
||||
dotnetcli,
|
||||
"build",
|
||||
"src"
|
||||
};
|
||||
success = runProcess(args, tmpdir);
|
||||
}
|
||||
catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean runProcess(String[] args, String path) throws Exception {
|
||||
ProcessBuilder pb = new ProcessBuilder(args);
|
||||
pb.directory(new File(path));
|
||||
Process process = pb.start();
|
||||
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
|
||||
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
|
||||
stdoutVacuum.start();
|
||||
stderrVacuum.start();
|
||||
process.waitFor();
|
||||
stdoutVacuum.join();
|
||||
stderrVacuum.join();
|
||||
boolean success = process.exitValue()==0;
|
||||
if ( !success ) {
|
||||
this.stderrDuringParse = stderrVacuum.toString();
|
||||
System.err.println("runProcess stderrVacuum: "+ this.stderrDuringParse);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
private void saveResourceAsFile(String resourceName, File file) throws IOException {
|
||||
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
|
||||
if ( input==null ) {
|
||||
|
@ -512,11 +629,29 @@ public class BaseCSharpTest implements RuntimeTestSupport /*, SpecialRuntimeTest
|
|||
}
|
||||
|
||||
private String[] getExecTestArgs(String exec, Path output, Path errorOutput) {
|
||||
if(isWindows())
|
||||
return new String[] { exec, new File(tmpdir, "input").getAbsolutePath(), output.toAbsolutePath().toString(), errorOutput.toAbsolutePath().toString() } ;
|
||||
if ( isWindows() ) {
|
||||
return new String[]{
|
||||
exec, new File(tmpdir, "input").getAbsolutePath(),
|
||||
output.toAbsolutePath().toString(),
|
||||
errorOutput.toAbsolutePath().toString()
|
||||
};
|
||||
}
|
||||
else {
|
||||
String mono = locateTool("mono");
|
||||
return new String[] { mono, exec, new File(tmpdir, "input").getAbsolutePath(), output.toAbsolutePath().toString(), errorOutput.toAbsolutePath().toString() };
|
||||
if (!NETSTANDARD) {
|
||||
String mono = locateTool("mono");
|
||||
return new String[] {
|
||||
mono, exec, new File(tmpdir, "input").getAbsolutePath(),
|
||||
output.toAbsolutePath().toString(),
|
||||
errorOutput.toAbsolutePath().toString()
|
||||
};
|
||||
}
|
||||
|
||||
String dotnet = locateTool("dotnet");
|
||||
return new String[] {
|
||||
dotnet, exec, new File(tmpdir, "src/input").getAbsolutePath(),
|
||||
output.toAbsolutePath().toString(),
|
||||
errorOutput.toAbsolutePath().toString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"projects": [
|
||||
"replace_this"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"imports": [
|
||||
"dnxcore50"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.1.0"
|
||||
},
|
||||
"CSharp": {
|
||||
"target": "Project",
|
||||
"version": "*"
|
||||
}
|
||||
},
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true,
|
||||
"outputName": "Test",
|
||||
"nowarn": [
|
||||
"CS3021"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>12962409-846e-4b80-933a-bc484d264132</ProjectGuid>
|
||||
<RootNamespace>Antlr4.Runtime.dotnet</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -1,42 +0,0 @@
|
|||
/* Copyright (c) 2012-2016 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.
|
||||
*/
|
||||
using Antlr4.Runtime.Atn;
|
||||
using Antlr4.Runtime.Sharpen;
|
||||
|
||||
namespace Antlr4.Runtime.Atn
|
||||
{
|
||||
/// <author>Sam Harwell</author>
|
||||
public class OrderedATNConfigSet : ATNConfigSet
|
||||
{
|
||||
public OrderedATNConfigSet()
|
||||
{
|
||||
}
|
||||
|
||||
public OrderedATNConfigSet(ATNConfigSet set, bool @readonly)
|
||||
: base(set, @readonly)
|
||||
{
|
||||
}
|
||||
|
||||
public override ATNConfigSet Clone(bool @readonly)
|
||||
{
|
||||
Antlr4.Runtime.Atn.OrderedATNConfigSet copy = new Antlr4.Runtime.Atn.OrderedATNConfigSet(this, @readonly);
|
||||
if (!@readonly && this.IsReadOnly)
|
||||
{
|
||||
copy.AddAll(this);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
protected internal override long GetKey(ATNConfig e)
|
||||
{
|
||||
return e.GetHashCode();
|
||||
}
|
||||
|
||||
protected internal override bool CanMerge(ATNConfig left, long leftKey, ATNConfig right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Antlr4.Runtime.Sharpen;
|
||||
|
||||
namespace Antlr4.Runtime.Dfa
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Antlr4.Runtime.Misc
|
||||
{
|
||||
public class DoubleKeyMap<K1, K2, V>
|
||||
{
|
||||
Dictionary<K1, Dictionary<K2, V>> data = new Dictionary<K1, Dictionary<K2, V>>();
|
||||
|
||||
public V put(K1 k1, K2 k2, V v)
|
||||
{
|
||||
Dictionary<K2, V> data2 = data.get(k1);
|
||||
V prev = null;
|
||||
if (data2 == null)
|
||||
{
|
||||
data2 = new Dict<K2, V>();
|
||||
data.put(k1, data2);
|
||||
}
|
||||
else {
|
||||
prev = data2.get(k2);
|
||||
}
|
||||
data2.put(k2, v);
|
||||
return prev;
|
||||
}
|
||||
|
||||
public V get(K1 k1, K2 k2)
|
||||
{
|
||||
Dictionary<K2, V> data2 = data.get(k1);
|
||||
if (data2 == null) return null;
|
||||
return data2.get(k2);
|
||||
}
|
||||
|
||||
public Dictionary<K2, V> get(K1 k1) { return data.get(k1); }
|
||||
|
||||
/** Get all values associated with primary key */
|
||||
public ICollection<V> values(K1 k1)
|
||||
{
|
||||
Dictionary<K2, V> data2 = data.get(k1);
|
||||
if (data2 == null) return null;
|
||||
return data2.values();
|
||||
}
|
||||
|
||||
/** get all primary keys */
|
||||
public HashSet<K1> keySet()
|
||||
{
|
||||
return data.keySet();
|
||||
}
|
||||
|
||||
/** get all secondary keys associated with a primary key */
|
||||
public HashSet<K2> keySet(K1 k1)
|
||||
{
|
||||
Dictionary<K2, V> data2 = data.get(k1);
|
||||
if (data2 == null) return null;
|
||||
return data2.keySet();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
* 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.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Antlr4.Runtime.Sharpen;
|
||||
|
||||
|
|
|
@ -354,7 +354,7 @@ namespace Antlr4.Runtime.Misc
|
|||
}
|
||||
foreach (Transition transition in state.transitions)
|
||||
{
|
||||
if (transition.TransitionType != TransitionType.Rule)
|
||||
if (transition.TransitionType != TransitionType.RULE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ namespace Antlr4.Runtime.Misc
|
|||
{
|
||||
}
|
||||
|
||||
#if PORTABLE
|
||||
#if PORTABLE || DOTNETCORE
|
||||
public interface ICustomAttributeProvider
|
||||
{
|
||||
object[] GetCustomAttributes(Type attributeType, bool inherit);
|
||||
|
@ -646,7 +646,11 @@ namespace Antlr4.Runtime.Misc
|
|||
StringBuilder errors = new StringBuilder();
|
||||
foreach (Tuple<RuleDependencyAttribute, ICustomAttributeProvider> dependency in dependencies)
|
||||
{
|
||||
if (!dependency.Item1.Recognizer.IsAssignableFrom(recognizerType))
|
||||
#if DOTNETCORE
|
||||
if (!dependency.Item1.Recognizer.GetTypeInfo().IsAssignableFrom(recognizerType))
|
||||
#else
|
||||
if (!dependency.Item1.Recognizer.IsAssignableFrom(recognizerType))
|
||||
#endif
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -773,7 +777,11 @@ namespace Antlr4.Runtime.Misc
|
|||
private static int[] GetRuleVersions(Type recognizerClass, string[] ruleNames)
|
||||
{
|
||||
int[] versions = new int[ruleNames.Length];
|
||||
#if DOTNETCORE
|
||||
FieldInfo[] fields = recognizerClass.GetTypeInfo().GetFields();
|
||||
#else
|
||||
FieldInfo[] fields = recognizerClass.GetFields();
|
||||
#endif
|
||||
foreach (FieldInfo field in fields)
|
||||
{
|
||||
bool isStatic = field.IsStatic;
|
||||
|
@ -805,7 +813,11 @@ namespace Antlr4.Runtime.Misc
|
|||
#endif
|
||||
continue;
|
||||
}
|
||||
#if DOTNETCORE
|
||||
RuleVersionAttribute ruleVersion = ruleMethod.GetCustomAttribute<RuleVersionAttribute>();
|
||||
#else
|
||||
RuleVersionAttribute ruleVersion = (RuleVersionAttribute)Attribute.GetCustomAttribute(ruleMethod, typeof(RuleVersionAttribute));
|
||||
#endif
|
||||
int version = ruleVersion != null ? ruleVersion.Version : 0;
|
||||
versions[index] = version;
|
||||
}
|
||||
|
@ -832,10 +844,18 @@ namespace Antlr4.Runtime.Misc
|
|||
|
||||
private static MethodInfo GetRuleMethod(Type recognizerClass, string name)
|
||||
{
|
||||
#if DOTNETCORE
|
||||
MethodInfo[] declaredMethods = recognizerClass.GetTypeInfo().GetMethods();
|
||||
#else
|
||||
MethodInfo[] declaredMethods = recognizerClass.GetMethods();
|
||||
#endif
|
||||
foreach (MethodInfo method in declaredMethods)
|
||||
{
|
||||
if (method.Name.Equals(name) && Attribute.IsDefined(method, typeof(RuleVersionAttribute)))
|
||||
#if DOTNETCORE
|
||||
if (method.Name.Equals(name) && method.IsDefined(typeof(RuleVersionAttribute)))
|
||||
#else
|
||||
if (method.Name.Equals(name) && Attribute.IsDefined(method, typeof(RuleVersionAttribute)))
|
||||
#endif
|
||||
{
|
||||
return method;
|
||||
}
|
||||
|
@ -845,7 +865,11 @@ namespace Antlr4.Runtime.Misc
|
|||
|
||||
private static string[] GetRuleNames(Type recognizerClass)
|
||||
{
|
||||
#if DOTNETCORE
|
||||
FieldInfo ruleNames = recognizerClass.GetTypeInfo().GetField("ruleNames");
|
||||
#else
|
||||
FieldInfo ruleNames = recognizerClass.GetField("ruleNames");
|
||||
#endif
|
||||
return (string[])ruleNames.GetValue(null);
|
||||
}
|
||||
|
||||
|
@ -853,20 +877,36 @@ namespace Antlr4.Runtime.Misc
|
|||
{
|
||||
IList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>> result = new ArrayList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>>();
|
||||
|
||||
#if DOTNETCORE
|
||||
GetElementDependencies(AsCustomAttributeProvider(clazz.GetTypeInfo()), result);
|
||||
#else
|
||||
GetElementDependencies(AsCustomAttributeProvider(clazz), result);
|
||||
#endif
|
||||
#if DOTNETCORE
|
||||
foreach (ConstructorInfo ctor in clazz.GetTypeInfo().GetConstructors(AllDeclaredMembers))
|
||||
#else
|
||||
foreach (ConstructorInfo ctor in clazz.GetConstructors(AllDeclaredMembers))
|
||||
#endif
|
||||
{
|
||||
GetElementDependencies(AsCustomAttributeProvider(ctor), result);
|
||||
foreach (ParameterInfo parameter in ctor.GetParameters())
|
||||
GetElementDependencies(AsCustomAttributeProvider(parameter), result);
|
||||
}
|
||||
|
||||
#if DOTNETCORE
|
||||
foreach (FieldInfo field in clazz.GetTypeInfo().GetFields(AllDeclaredMembers))
|
||||
#else
|
||||
foreach (FieldInfo field in clazz.GetFields(AllDeclaredMembers))
|
||||
#endif
|
||||
{
|
||||
GetElementDependencies(AsCustomAttributeProvider(field), result);
|
||||
}
|
||||
|
||||
#if DOTNETCORE
|
||||
foreach (MethodInfo method in clazz.GetTypeInfo().GetMethods(AllDeclaredMembers))
|
||||
#else
|
||||
foreach (MethodInfo method in clazz.GetMethods(AllDeclaredMembers))
|
||||
#endif
|
||||
{
|
||||
GetElementDependencies(AsCustomAttributeProvider(method), result);
|
||||
#if COMPACT
|
||||
|
@ -922,12 +962,21 @@ namespace Antlr4.Runtime.Misc
|
|||
|
||||
private static string GetSerializedATN(Type recognizerClass)
|
||||
{
|
||||
#if DOTNETCORE
|
||||
FieldInfo serializedAtnField = recognizerClass.GetTypeInfo().GetField("_serializedATN", AllDeclaredStaticMembers);
|
||||
#else
|
||||
FieldInfo serializedAtnField = recognizerClass.GetField("_serializedATN", AllDeclaredStaticMembers);
|
||||
#endif
|
||||
if (serializedAtnField != null)
|
||||
return (string)serializedAtnField.GetValue(null);
|
||||
|
||||
#if DOTNETCORE
|
||||
if (recognizerClass.GetTypeInfo().BaseType != null)
|
||||
return GetSerializedATN(recognizerClass.GetTypeInfo().BaseType);
|
||||
#else
|
||||
if (recognizerClass.BaseType != null)
|
||||
return GetSerializedATN(recognizerClass.BaseType);
|
||||
#endif
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ namespace Antlr4.Runtime
|
|||
return null;
|
||||
}
|
||||
|
||||
#if NET45PLUS
|
||||
#if (NET45PLUS && !DOTNETCORE)
|
||||
public virtual IReadOnlyList<ITerminalNode> GetTokens(int ttype)
|
||||
#else
|
||||
public virtual ITerminalNode[] GetTokens(int ttype)
|
||||
|
@ -310,7 +310,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
return Collections.EmptyList<ITerminalNode>();
|
||||
}
|
||||
#if NET45PLUS
|
||||
#if (NET45PLUS && !DOTNETCORE)
|
||||
return tokens;
|
||||
#else
|
||||
return tokens.ToArray();
|
||||
|
@ -323,7 +323,7 @@ namespace Antlr4.Runtime
|
|||
return GetChild<T>(i);
|
||||
}
|
||||
|
||||
#if NET45PLUS
|
||||
#if (NET45PLUS && !DOTNETCORE)
|
||||
public virtual IReadOnlyList<T> GetRuleContexts<T>()
|
||||
where T : Antlr4.Runtime.ParserRuleContext
|
||||
#else
|
||||
|
@ -351,7 +351,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
return Collections.EmptyList<T>();
|
||||
}
|
||||
#if NET45PLUS
|
||||
#if (NET45PLUS && !DOTNETCORE)
|
||||
return contexts;
|
||||
#else
|
||||
return contexts.ToArray();
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2016 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
|
||||
#if PORTABLE || DOTNETCORE
|
||||
|
||||
namespace System
|
||||
{
|
||||
|
@ -14,3 +14,4 @@ namespace System
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ using System;
|
|||
using System.Threading;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Antlr4.Runtime.Sharpen
|
||||
{
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
* 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 NET40PLUS
|
||||
using System.Collections.Concurrent;
|
||||
#else
|
||||
using Antlr4.Runtime.Sharpen;
|
||||
#endif
|
||||
|
||||
namespace Antlr4.Runtime.Tree
|
||||
{
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace Antlr4.Runtime.Tree.Pattern
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class StartRuleDoesNotConsumeFullPattern : Exception
|
||||
{
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Antlr4.Runtime.dotnet", "Antlr4.Runtime\Antlr4.Runtime.dotnet.xproj", "{12962409-846E-4B80-933A-BC484D264132}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{12962409-846E-4B80-933A-BC484D264132}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{12962409-846E-4B80-933A-BC484D264132}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{12962409-846E-4B80-933A-BC484D264132}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{12962409-846E-4B80-933A-BC484D264132}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
|
@ -21,4 +20,4 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
EndGlobal
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"version": "4.6.1-*",
|
||||
"frameworks": {
|
||||
"netstandard1.3": {
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.6.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {},
|
||||
"buildOptions": {
|
||||
"outputName": "Antlr4.Runtime.Standard",
|
||||
"xmlDoc": true,
|
||||
"keyFile": "../Antlr4.snk",
|
||||
"define": [
|
||||
"DOTNETCORE",
|
||||
"NET40PLUS",
|
||||
"NET45PLUS"
|
||||
],
|
||||
"nowarn": [
|
||||
"CS1591",
|
||||
"CS1574",
|
||||
"CS1580"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue