Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
####### | ||
nimly | ||
####### | ||
|
||
nimly はコンパイラ言語 Nim のための、 | ||
lexer generator である niml と, parser generator である nimy からなる | ||
ライブラリです。 | ||
|
||
面白い点 | ||
======== | ||
nimly では Nim の強力で自由度の高いマクロとコンパイル時計算を利用し、 | ||
Nim の言語機能に密着した方法での lexer と parser の生成を行っています。 | ||
|
||
マクロによる文法の拡張 | ||
---------------------- | ||
Nim のマクロはコンパイラによるソースのパースの後、 | ||
指定されている部分の AST を入力とし、その部分を | ||
コンパイル時関数実行によって得られた別の AST で置き換える機能です。 | ||
|
||
この機能により、niml では lex の記法に似た記法で | ||
生成する lexer を記述することができ、 | ||
また nimy では BNF に似た記法により parser を記述する事ができるように | ||
しています。 | ||
|
||
オートマトンのコンパイル時計算 | ||
------------------------------ | ||
Nim は vm を使用したコンパイル時関数実行の機能を有しています。 | ||
|
||
niml, nimy は共に、Nim のコンパイル時計算の機能を使用しており、 | ||
上記の方法で生成した AST はオートマトンをコンパイル時に | ||
計算、生成するコードになっています。 | ||
これにより、lexer, parser の生成を実行時から切り離すことと、 | ||
lexer, parser を Nim によって生成すること、また、それらを利用するコード | ||
との円滑な接続、例えばオートマトン生成前の型検査等の両立を可能にしています。 |