Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

パーサーの仕様を変更 #130

Merged
merged 25 commits into from
Jun 4, 2024
Merged

パーサーの仕様を変更 #130

merged 25 commits into from
Jun 4, 2024

Conversation

noya2ruler
Copy link
Collaborator

@noya2ruler noya2ruler commented May 26, 2024

fix #65
fix #71

大量の仕様変更を行なっている;

大きめの変更

  • パーサーが根ノードを定義して返す仕様から、引数で根ノードを与えてパーサーは void を返す仕様に変更
  • NonLeafLeaf の区別を撤廃
  • 複数行にわたるブロックのパースを補助する Reader クラスを作成
  • Block 構文と Inline 構文を定義、パーサーを関数オブジェクトとして提供させる仕様にした
  • インライン記法はブロック記法を含まない限り先の行まで読み続けるべきなので、そのような仕様になるようパーサーの実装を変更

小さめの変更

  • 保持する uuid を int に変更
  • Block::render が担っていた機能を to_html が担うよう変更、render を削除
  • InlineParser はインスタンスを生成せずに文字列をパースできる仕様に変更
  • ファイル終端の構文 EOF を追加、なお、これはASTには現れない
  • RawText は特別にパーサーを持たず、 InlineParser が実質的なパーサーを担当する
  • to_dot は根ノードかどうかのフラグを受け取る仕様から、呼び出し側が返り値の文字列を加工させる仕様に変更( render.hppmd_to_dot を参照のこと)

インターフェースと実装、および構文ごとのノード定義を分離した
LeafNodeとNonLeafNodeの区別がなくなったことに伴い、仕様を変更。根かどうかのフラグを渡す仕様から、呼び出し側で加工させる仕様に変更した。
Markdown全体のパースを補助するクラス reader を実装した。メタデータの取り出しは reader を経由して行うが、未実装。
具体的な構文のパース方法については別個定義するように設計を見直した。
@noya2ruler noya2ruler requested a review from abap34 May 26, 2024 10:08
Copy link
Owner

@abap34 abap34 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとう!
ロジックのところは後でじっくりみます。これだけ先に修正お願いします

@noya2ruler
Copy link
Collaborator Author

すべての構文を定義し終えて、example/example.md は完全にパースできるようになりました。

  • bash scripts/setup.sh
  • g++ -std=c++20 build/almo.cpp -o newalmo
  • ./newalmo example/example.md -o example.html

とかで試せるはず。

@abap34 abap34 marked this pull request as ready for review May 30, 2024 05:26
@abap34 abap34 self-requested a review May 30, 2024 05:27
@abap34 abap34 added the parser label Jun 1, 2024
@abap34
Copy link
Owner

abap34 commented Jun 4, 2024

良さそうです。お疲れ様でした! 🎉

@abap34 abap34 merged commit dd09f27 into main Jun 4, 2024
@noya2ruler noya2ruler deleted the feat/#65 branch June 4, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AST・中間表現の出力の設計の見直し パースの実装のリファクタリング
2 participants