タグ

Pythonとpyparsingに関するxiangzeのブックマーク (2)

  • Pythonでコンパイラ: PL/0抽象構文木(AST) - Qiita

    今回の目標 前回はparse treeの作成に必要なpyparsingの機能を理解しました。今回は3番の抽象構文木(AST)生成を行います。 パーサーでトークンに分解する。 トークンから構文木をつくる方法、式の構文木の作成 setParseAction()を使って抽象構文木(AST)を生成 <- 今ココ ASTノードを辿ってコードを生成する。 ASTノード ノードを定義するにあたっては次の点に注意します。 ASTノードはpyparsingの実装から切り離す。 ツリーの探索が簡単にできるようする。具体的には共通のベースクラスを持たせる。 ノードがコード生成の最小単位であるから、一つのノードの役割を大きくしない。 では実装です。pl0_nodes.pyというファイルを新規に作成します。このファイルではpyparsingはインポートしません。ベースクラスはprintしたときに、クラス名とフィール

    Pythonでコンパイラ: PL/0抽象構文木(AST) - Qiita
  • Wikispaces

    We are sorry, but the site you are looking for no longer exists Wikispaces was founded in 2005 and has since been used by educators, companies and individuals across the globe. Unfortunately, the time has come where we have had to make the difficult business decision to end the Wikispaces service. We first announced the site closure in January 2018, through a site-wide banner that appeared to all

  • 1