はじめに プログラムを書いていると、ちょっとした言語処理系を作りたくなることがあります。ちょっとした言語処理系を作ろうとしたとき、OCamlは良い選択肢です。何故良い選択肢なのかはよくわかりませんが、実際書いてみて快適でしたし、えらい人もそう言ってましたし、まあいいや、とにかく良い選択肢です。 しかし、素のOCamlで構文解析器や字句解析器を作るのはしんどいです。手を抜こうと思ったら構文解析器生成器Menhirと字句解析器生成器ocamllexを使うのが常套手段でしょう。 が、普通の人はそう頻繁に新しく言語処理系を作ったりしませんので、 Menhir や ocamllex の使い方を忘れがちです。こうなると困ります。例えば「半年ぶりに言語処理系を作りたい気分になっちゃった」というとき、「あれっ? Menhir ってどう書くんだっけ?」となり、こうなると気分が重くなり、結果「言語処理系つくら
CIL is a front-end for the C programming language that facilitates program analysis and transformation. CIL will parse and typecheck a program, and compile it into a simplified subset of C. goblint-cil is a fork of CIL that supports C99, C11 as well as most of the extensions of the GNU C. It makes many changes to the original CIL in an effort to modernize it and keep up with the latest versions of
parolというLL(k)パーサを生成するcrateがあるのですが、とにかくすごいので紹介します。 parolを知って、Rustでパーサをつくることに関して新しい時代が始まったなと思いました。 パーサコンビネータ Rustでパーサといえばnomやchumskyといったパーサコンビネータが主流の印象です。 これはjsonのように既に文法が定義されている場合やプログラミング言語のプロトタイピングに向いていると思います。 nomのREADMEにも後者について以下のように言及されています。 While programming language parsers are usually written manually for more flexibility and performance, nom can be (and has been successfully) used as a proto
It seems that GCC and LLVM-Clang are using handwritten recursive descent parsers, and not machine generated, Bison-Flex based, bottom up parsing. Could someone here please confirm that this is the case? And if so, why do mainstream compiler frameworks use handwritten parsers? Update : interesting blog on this topic here
Dick Grune and Ceriel J.H. Jacobs VU University Amsterdam, The Netherlands Published (2008) by Springer US, ISBN 978-1-4419-1901-4 Originally published by Ellis Horwood, Chichester, England, 1990; ISBN 0 13 651431 6 The Table of Contents can be found here. Description This 622-page book treats parsing in its own right, in greater depth than is found in most computer science and linguistics books.
The package is built around MonadParsec, an MTL-style monad transformer. Most features work with all instances of MonadParsec. One can achieve various effects combining monad transformers, i.e. building a monadic stack. Since the common monad transformers like WriterT, StateT, ReaderT and others are instances of the MonadParsec type class, one can also wrap ParsecT in these monads, achieving, for
Reading and writing binary formats is hard, especially if it’s an interchange format that should work across a multitude of platforms and languages. Have you ever found yourself writing repetitive, error-prone and hard-to-debug code that reads binary data structures from files or network streams and somehow represents them in memory for easier access? Kaitai Struct tries to make this job easier —
前回、基本的なファイルの読み書きに関してまとめたので、今回は XML の要素を取得したり、検索する方法についてのメモです。 要素を名前から取得するには、getElementsByTagName(“要素名”) を使います。 <data> ノードの中にある最初の <sample> ノードの内容を表示するサンプルがこちらです。 <?xml version="1.0" encoding="utf-8"?> <data> <sample id="1">red</sample> <sample id="2">green</sample> <sample id="3">test</sample> <sample id="4">blue</sample> <sample id="5">white</sample> <sample id="6">yellow</sample> </data> <?php $
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く