Bve5_Parsing 1.0.1

dotnet add package Bve5_Parsing --version 1.0.1
NuGet\Install-Package Bve5_Parsing -Version 1.0.1
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="Bve5_Parsing" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bve5_Parsing --version 1.0.1
#r "nuget: Bve5_Parsing, 1.0.1"
#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 Bve5_Parsing as a Cake Addin
#addin nuget:?package=Bve5_Parsing&version=1.0.1

// Install Bve5_Parsing as a Cake Tool
#tool nuget:?package=Bve5_Parsing&version=1.0.1

Build Status All Contributors NuGet version MIT License

Bve5_Parsing

bve5PasingImage

BveTrainSim5構文の.NETパーサライブラリです。 入力された文字列やファイルを解析し、プログラム上で利用しやすい形式に変換します。 現在マップファイルとシナリオファイル構文に対応しています。

Supported Syntaxes

  • Scenario File
    • Bve5の全構文に対応
  • Map File
    • マップファイルのバージョン1.00から2.02に対応。
    • 数式や変数、Includeディレクティブにも対応しています。

その他は今後作っていきます👍

Requirements

  • .Net Standard 2.0 or .Net framework 4.0

Installation

NugetでBve5_Parsingとしてパッケージを公開しています。

  • コマンドラインからインストールする場合

    nuget install Bve5_Parsing
    
  • VisualStudioからインストールする場合

    1. ツール > Nugetパッケージマネージャ > ソリューションのNugetパッケージの管理をクリック
    2. 参照タブでBve5_Parsingを検索
    3. インストールをクリック

Usage for C#

C#でマップファイルのパースを行う場合

using Bve5_Parsing.MapGrammar;
using Bve5_Parsing.MapGrammar.EvaluateData;
using System.Linq;

...
    string input; //String to be analyzed
    MapGrammarParser parser = new MapGrammarParser();

    // 文字列をマップ構文としてパースする
    MapData mapData = parser.Parse(input);
    // マップファイルへのファイルパスを指定してパースする
    MapData mapData2 = parser.ParseFromFile(@"PATH/TO/MAP/FILE");
    // Include構文の参照先を再帰的にパースする
    MapData mapDataWithInclude = parser.ParseFromFile(@"PATH/TO/MAP/FILE", MapGrammarParserOption.ParseIncludeSyntaxRecursively)
    // AST(抽象構文木)にパースする
    MapData ast = parser.ParseToAst(input, @"PATH/TO/FILE/PATH");

    // パースエラーの取得
    if (parser.ParseErrors.Any()) {
      // error handling
    }

    // 旧形式でステートメントのデータを取得する場合(通常は必要ありません)
    var syntaxData = mapData.Statements.Select(state => state.ToSyntaxData());

    mapData.Version //マップ構文のバージョン情報
    mapData.Encoding // マップ構文のエンコーディング指定
    foreach(var statement in mapData.Statements) {
      /* 各構文情報 */
      statement.Distance; //構文の距離程
      statement.FunctionName; //構文の関数名
    }
...

パース処理に成功した場合、結果はMapDataクラスで返ってきます。例えば、ファイルヘッダのバージョン情報はMapData.Versionに格納されています。また、構文解析のエラーはMapGrammarParser.ParserErrorsに格納されています。MapGrammarParser.ParserErrorsではエラーの種別(警告かエラーか)やエラーとなった構文の位置、エラーメッセージが取得出来ます。独自のエラーメッセージを実装する場合は、ParserErrorListenerを継承したカスタムクラスを実装し、MapGrammarParser.ErrorListenerに指定して下さい。

Bve5_Parsing.slnに含まれているParseSampleAppプロジェクトからは、コンソール上でパーサの動作を確かめることができます。Bve5_Parsingの実装例として適宜利用して下さい。

Used Librarys

Bve5_Parsing is using the following library.

ANTLR v4

The BSD License (3-clause BSD License)

Copyright (c) 2012 Terence Parr and Sam Harwell

ReadJEnc

The MIT License (MIT)

Copyright (c) 2017 hnx8

License

The MIT License (MIT)

Copyright(c) 2017-2019 aoisupersix

License.md

TechnicalCommentary

Bve5_Parsingの技術解説です。
TechnicalCommentary.md

Contributors

Thanks goes to these wonderful people (emoji key):

<table><tr><td align="center"><a href="https://aoisupersix.tokyo/"><img src="https://avatars0.githubusercontent.com/u/17172912?v=4" width="100px;" alt="Aoi Tanaka"/><br /><sub><b>Aoi Tanaka</b></sub></a><br /><a href="https://github.com/aoisupersix/Bve5_Parsing/commits?author=aoisupersix" title="Code">💻</a></td><td align="center"><a href="https://twitter.com/S520_BVE"><img src="https://avatars3.githubusercontent.com/u/29241703?v=4" width="100px;" alt="s520"/><br /><sub><b>s520</b></sub></a><br /><a href="https://github.com/aoisupersix/Bve5_Parsing/commits?author=s520" title="Code">💻</a></td></tr></table>

This project follows the all-contributors specification. Contributions of any kind welcome!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1 747 6/9/2019
1.0.0 668 4/27/2019
0.8.1 635 4/13/2019
0.8.0 626 4/10/2019
0.7.0 597 2/25/2019
0.6.2 735 10/23/2018
0.6.1 721 10/23/2018
0.6.0 715 10/22/2018