Cyjb.Compilers.Design
1.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Cyjb.Compilers.Design --version 1.0.3
NuGet\Install-Package Cyjb.Compilers.Design -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cyjb.Compilers.Design" Version="1.0.3"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cyjb.Compilers.Design --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Cyjb.Compilers.Design, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Cyjb.Compilers.Design as a Cake Addin #addin nuget:?package=Cyjb.Compilers.Design&version=1.0.3 // Install Cyjb.Compilers.Design as a Cake Tool #tool nuget:?package=Cyjb.Compilers.Design&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Cyjb.Compilers.Design
允许通过设计时 T4 模板生成词法分析器和语法分析器的实现。
使用方式:
通过 nuget 依赖运行时 Cyjb.Compilers.Runtim。
通过 nuget 依赖生成器 Cyjb.Compilers.Design,注意需要指定
GeneratePathProperty="true"
。
<ItemGroup>
<PackageReference Include="Cyjb.Compilers.Design" Version="1.0.0" GeneratePathProperty="true" />
</ItemGroup>
- 编写词法分析器或语法分析器的控制器类,例如:
using Cyjb.Compilers.Lexers;
enum Calc { Id, Add, Sub, Mul, Div, Pow, LBrace, RBrace }
[LexerSymbol("\\+", Kind = Calc.Add)]
[LexerSymbol("\\-", Kind = Calc.Sub)]
[LexerSymbol("\\*", Kind = Calc.Mul)]
[LexerSymbol("\\/", Kind = Calc.Div)]
[LexerSymbol("\\^", Kind = Calc.Pow)]
[LexerSymbol("\\(", Kind = Calc.LBrace)]
[LexerSymbol("\\)", Kind = Calc.RBrace)]
[LexerSymbol("\\s")]
// 必须是部分类,且继承自 LexerController<Calc>
public partial class TestCalcController : LexerController<Calc>
{
/// <summary>
/// 数字的终结符定义。
/// </summary>
[LexerSymbol("[0-9]+", Kind = Calc.Id)]
public void DigitAction()
{
Value = int.Parse(Text);
Accept();
}
}
- 添加与词法分析器同名的 tt 文件,内容如下:
<#@ include file="$(PkgCyjb_Compilers_Design)\content\CompilerTemplate.t4" #>
运行 T4 模板后即可生成同名的 .lexer.cs
文件,包含了词法分析器的实现。
欢迎访问我的博客获取更多信息。
C# 词法分析器系列博文
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.22 | 118 | 6/4/2024 |
1.0.21 | 115 | 6/4/2024 |
1.0.20 | 131 | 3/23/2024 |
1.0.19 | 135 | 3/20/2024 |
1.0.18 | 129 | 3/15/2024 |
1.0.17 | 115 | 3/14/2024 |
1.0.16 | 153 | 1/15/2024 |
1.0.15 | 247 | 3/10/2023 |
1.0.14 | 233 | 3/3/2023 |
1.0.13 | 242 | 2/9/2023 |
1.0.12 | 329 | 1/28/2023 |
1.0.11 | 286 | 1/25/2023 |
1.0.10 | 291 | 1/24/2023 |
1.0.9 | 267 | 1/23/2023 |
1.0.8 | 295 | 1/16/2023 |
1.0.7 | 340 | 12/4/2022 |
1.0.6 | 426 | 11/1/2022 |
1.0.5 | 477 | 10/25/2022 |
1.0.4 | 470 | 9/7/2022 |
1.0.3 | 461 | 8/27/2022 |
1.0.2 | 472 | 8/27/2022 |
1.0.1 | 474 | 8/18/2022 |
1.0.0 | 452 | 8/18/2022 |