Skip to content

Commit 26e3658

Browse files
committed
Merge branch 'master' of https://github.com/wiredwiz/Grun.Net
2 parents 29931be + 3565c91 commit 26e3658

37 files changed

+1013
-126
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '15 15 * * 6'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'csharp' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1

.github/workflows/dotnetdesktop.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v1
1111
- name: Setup Nuget.exe
12-
uses: warrenbuckley/Setup-Nuget@v1
12+
uses: nuget/setup-nuget@v1
1313
- name: Restore packages
1414
run: nuget restore Grun.Net.sln
15-
- name: Setup MSBuild.exe
16-
uses: warrenbuckley/Setup-MSBuild@v1
15+
- name: Setting up MSBuild
16+
uses: microsoft/setup-msbuild@v1.0.2
1717
- name: Build with MSBuild
1818
run: msbuild Grun.Net.sln -p:Configuration=Release

Code Grapher/Code Grapher.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
<Reference Include="Antlr4.Runtime, Version=4.6.0.0, Culture=neutral, PublicKeyToken=09abb75b9ed49849, processorArchitecture=MSIL">
3535
<HintPath>..\packages\Antlr4.Runtime.4.6.6\lib\net45\Antlr4.Runtime.dll</HintPath>
3636
</Reference>
37-
<Reference Include="Microsoft.Msagl, Version=3.0.0.0, Culture=neutral, PublicKeyToken=640c57aa40e7ae7d, processorArchitecture=MSIL">
38-
<HintPath>..\packages\Microsoft.Msagl.1.1.3\lib\net40\Microsoft.Msagl.dll</HintPath>
37+
<Reference Include="AutomaticGraphLayout">
38+
<HintPath>..\References\AutomaticGraphLayout.dll</HintPath>
3939
</Reference>
40-
<Reference Include="Microsoft.Msagl.Drawing, Version=3.0.0.0, Culture=neutral, PublicKeyToken=8a3d7c21d5fa1306, processorArchitecture=MSIL">
41-
<HintPath>..\packages\Microsoft.Msagl.Drawing.1.1.3\lib\net40\Microsoft.Msagl.Drawing.dll</HintPath>
40+
<Reference Include="AutomaticGraphLayout.Drawing">
41+
<HintPath>..\References\AutomaticGraphLayout.Drawing.dll</HintPath>
4242
</Reference>
4343
<Reference Include="System" />
4444
<Reference Include="System.Core" />

Code Grapher/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.20087.0")]
36-
[assembly: AssemblyFileVersion("1.1.20087.0")]
35+
[assembly: AssemblyVersion("1.2.21215.2")]
36+
[assembly: AssemblyFileVersion("1.2.21215.2")]

Code Grapher/packages.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Antlr4.Runtime" version="4.6.6" targetFramework="net461" />
4-
<package id="Microsoft.Msagl" version="1.1.3" targetFramework="net461" />
5-
<package id="Microsoft.Msagl.Drawing" version="1.1.3" targetFramework="net461" />
64
</packages>

Common/Grammar/Place.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535
#endregion
3636

37+
using Antlr4.Runtime;
38+
39+
using JetBrains.Annotations;
40+
41+
using Org.Edgerunner.ANTLR4.Tools.Common.Extensions;
42+
3743
namespace Org.Edgerunner.ANTLR4.Tools.Common.Grammar
3844
{
3945
/// <summary>

Common/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.20087.0")]
36-
[assembly: AssemblyFileVersion("1.1.20087.0")]
35+
[assembly: AssemblyVersion("1.2.21215.2")]
36+
[assembly: AssemblyFileVersion("1.2.21215.2")]

Grun/Grun.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -36,20 +36,20 @@
3636
<Reference Include="Antlr4.Runtime, Version=4.6.0.0, Culture=neutral, PublicKeyToken=09abb75b9ed49849, processorArchitecture=MSIL">
3737
<HintPath>..\packages\Antlr4.Runtime.4.6.6\lib\net45\Antlr4.Runtime.dll</HintPath>
3838
</Reference>
39+
<Reference Include="AutomaticGraphLayout">
40+
<HintPath>..\References\AutomaticGraphLayout.dll</HintPath>
41+
</Reference>
42+
<Reference Include="AutomaticGraphLayout.Drawing">
43+
<HintPath>..\References\AutomaticGraphLayout.Drawing.dll</HintPath>
44+
</Reference>
3945
<Reference Include="Colorful.Console, Version=1.2.10.0, Culture=neutral, processorArchitecture=MSIL">
4046
<HintPath>..\packages\Colorful.Console.1.2.10\lib\net461\Colorful.Console.dll</HintPath>
4147
</Reference>
4248
<Reference Include="CommandLine, Version=2.7.82.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
4349
<HintPath>..\packages\CommandLineParser.2.7.82\lib\net461\CommandLine.dll</HintPath>
4450
</Reference>
45-
<Reference Include="Microsoft.Msagl, Version=3.0.0.0, Culture=neutral, PublicKeyToken=640c57aa40e7ae7d, processorArchitecture=MSIL">
46-
<HintPath>..\packages\Microsoft.Msagl.1.1.3\lib\net40\Microsoft.Msagl.dll</HintPath>
47-
</Reference>
48-
<Reference Include="Microsoft.Msagl.Drawing, Version=3.0.0.0, Culture=neutral, PublicKeyToken=8a3d7c21d5fa1306, processorArchitecture=MSIL">
49-
<HintPath>..\packages\Microsoft.Msagl.Drawing.1.1.3\lib\net40\Microsoft.Msagl.Drawing.dll</HintPath>
50-
</Reference>
51-
<Reference Include="Microsoft.Msagl.GraphViewerGdi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=fffc27ea4058b3a1, processorArchitecture=MSIL">
52-
<HintPath>..\packages\Microsoft.Msagl.GraphViewerGDI.1.1.3\lib\net40\Microsoft.Msagl.GraphViewerGdi.dll</HintPath>
51+
<Reference Include="Microsoft.Msagl.GraphViewerGdi">
52+
<HintPath>..\References\Microsoft.Msagl.GraphViewerGdi.dll</HintPath>
5353
</Reference>
5454
<Reference Include="System" />
5555
<Reference Include="System.Configuration" />

Grun/Options.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@
3434
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535
#endregion
3636

37+
using System.Diagnostics.CodeAnalysis;
38+
3739
using CommandLine;
3840

3941
namespace Org.Edgerunner.ANTLR4.Tools.Testing.Grun
4042
{
4143
/// <summary>
4244
/// Class that represents command line options.
4345
/// </summary>
46+
[SuppressMessage("ReSharper", "StyleCop.SA1600", Justification = "Option attributes already describe them well enough")]
4447
public class Options
4548
{
4649
[Value(0, MetaName = "Grammar Name", HelpText = "ANTLR grammar to load", Required = true)]

Grun/Program.cs

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
using System.IO;
4242
using System.Linq;
4343
using System.Reflection;
44+
using System.Runtime.InteropServices;
4445
using System.Text;
4546
using System.Windows.Forms;
4647

4748
using Antlr4.Runtime.Misc;
48-
49+
using Colorful;
4950
using CommandLine;
5051
using CommandLine.Text;
5152

@@ -84,16 +85,23 @@ internal class Program
8485

8586
#region Static
8687

88+
[DllImport("kernel32.dll", EntryPoint = "SetConsoleMode", SetLastError = true,
89+
CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
90+
private static extern bool SetConsoleMode(int hConsoleHandle, int dwMode);
91+
8792
[STAThread]
8893
// ReSharper disable once MethodTooLong
8994
private static void Main(string[] args)
9095
{
9196
try
9297
{
9398
LoadApplicationSettings();
94-
//Console.BackgroundColor = _Settings.EditorBackgroundColor;
95-
//Console.ForegroundColor = _Settings.EditorTextColor;
96-
//FillCurrentLineBackground();
99+
//if (_Settings.EnableConsoleSyntaxHighlighting)
100+
//{
101+
// Console.BackgroundColor = _Settings.EditorBackgroundColor;
102+
// Console.ForegroundColor = _Settings.EditorTextColor;
103+
// Console.Clear();
104+
//}
97105

98106
var parser = new Parser(with => with.HelpWriter = null);
99107
var parserResult = parser.ParseArguments<Options>(args);
@@ -138,11 +146,12 @@ private static void Main(string[] args)
138146
return;
139147
}
140148

141-
// To be used later once syntax highlighting for the console is enabled.
149+
//// To be used later once syntax highlighting for the console is enabled.
142150
//var guideResult = grammar.LoadSyntaxHighlightingGuide();
143151
//guide = guideResult != null ? guideResult.Item2 : new HeuristicSyntaxHighlightingGuide(_Settings);
144152

145153
string data;
154+
var analyzer = new Analyzer();
146155

147156
if (!string.IsNullOrEmpty(o.FileName))
148157
{
@@ -158,7 +167,6 @@ private static void Main(string[] args)
158167
}
159168
else
160169
{
161-
//var analyzer = new Analyzer();
162170
var builder = new StringBuilder();
163171
Console.WriteLine(Resources.ReadingFromStandardInputPromptMessage);
164172
var currentLine = Console.CursorTop;
@@ -195,14 +203,14 @@ private static void Main(string[] args)
195203
}
196204
else if (typed.Key == ConsoleKey.Backspace)
197205
{
198-
if (Console.CursorLeft > 0)
199-
{
200-
Console.Write(typed.KeyChar);
201-
Console.Write(' ');
202-
Console.Write(typed.KeyChar);
203-
builder.Remove(builder.Length - 1, 1);
204-
_Cache.FlushTokensForLine(currentLine - (_ScrollFadeCount + 1));
205-
}
206+
if (Console.CursorLeft <= 0)
207+
continue;
208+
209+
Console.Write(typed.KeyChar);
210+
Console.Write(' ');
211+
Console.Write(typed.KeyChar);
212+
builder.Remove(builder.Length - 1, 1);
213+
_Cache.FlushTokensForLine(currentLine - (_ScrollFadeCount + 1));
206214
}
207215
else
208216
{
@@ -211,8 +219,11 @@ private static void Main(string[] args)
211219
}
212220
}
213221

214-
//analyzer.Tokenize(grammar, builder.ToString());
215-
//HighlightSyntaxInConsole(currentLine - (_ScrollFadeCount + 1), analyzer, guide);
222+
//if (_Settings.EnableConsoleSyntaxHighlighting)
223+
//{
224+
// analyzer.Tokenize(grammar, builder.ToString(), null);
225+
// HighlightSyntaxInConsole(currentLine - (_ScrollFadeCount + 1), analyzer, guide);
226+
//}
216227
}
217228
}
218229

@@ -223,15 +234,14 @@ private static void Main(string[] args)
223234
// If tokens are the only option we've received, we don't need to parse
224235
if (options == Grammar.ParseOption.Tokens)
225236
{
226-
DisplayTokens(grammar, data);
237+
DisplayTokens(grammar, analyzer, data);
227238
return;
228239
}
229240

230241
// Now we attempt to parse, but still handle a lexer-only grammar.
231242
if (grammar.Parser != null)
232243
{
233-
var analyzer = new Analyzer();
234-
var grammarParser = analyzer.BuildParserWithOptions(grammar, data, options);
244+
var grammarParser = analyzer.BuildParserWithOptions(grammar, data, options, null);
235245
analyzer.ExecuteParsing(grammarParser, o.RuleName);
236246

237247
if (showParseTree)
@@ -257,7 +267,7 @@ private static void Main(string[] args)
257267
else
258268
{
259269
if (options.HasFlag(ParseOption.Tokens))
260-
DisplayTokens(grammar, data);
270+
DisplayTokens(grammar, analyzer, data);
261271

262272
if (showParseTree || writeSvg)
263273
Console.WriteLine(Resources.GrammarHasNoParserErrorMessage, grammar.GrammarName);
@@ -351,26 +361,23 @@ private static void FillCurrentLineBackground()
351361
Console.SetCursorPosition(cursorColumn, cursorRow);
352362
}
353363

354-
private static void DisplayTokens(GrammarReference grammar, string data)
364+
private static void DisplayTokens(GrammarReference grammar, Analyzer analyzer, string data)
355365
{
356-
var analyzer = new Grammar.Analyzer();
357-
var tokens = analyzer.Tokenize(grammar, data);
366+
var tokens = analyzer.Tokenize(grammar, data, null);
358367
foreach (var token in tokens)
359368
Console.WriteLine(token.ToString());
360369
}
361370

362371
private static void LoadGui(string data, GrammarReference grammar, string parserRule)
363372
{
364-
{
365-
Application.EnableVisualStyles();
366-
Application.SetCompatibleTextRenderingDefault(false);
367-
var visualAnalyzer = new VisualAnalyzer();
368-
visualAnalyzer.SetSourceCode(data);
369-
visualAnalyzer.SetGrammar(grammar);
370-
if (grammar.Parser != null || !parserRule.Equals("tokens", StringComparison.InvariantCultureIgnoreCase))
371-
visualAnalyzer.SetDefaultParserRule(parserRule);
372-
Application.Run(visualAnalyzer);
373-
}
373+
Application.EnableVisualStyles();
374+
Application.SetCompatibleTextRenderingDefault(false);
375+
var visualAnalyzer = new VisualAnalyzer();
376+
visualAnalyzer.SetSourceCode(data);
377+
visualAnalyzer.SetGrammar(grammar);
378+
if (grammar.Parser != null || !parserRule.Equals("tokens", StringComparison.InvariantCultureIgnoreCase))
379+
visualAnalyzer.SetDefaultParserRule(parserRule);
380+
Application.Run(visualAnalyzer);
374381
}
375382

376383
/// <summary>

0 commit comments

Comments
 (0)