@article{oai:ipsj.ixsq.nii.ac.jp:00184909,
 author = {今泉, 良紀 and 篠埜, 功 and Yoshiki, Imaizumi and Isao, Sasano},
 issue = {6},
 journal = {情報処理学会論文誌プログラミング(PRO)},
 month = {Dec},
 note = {パックラット構文解析ではLALR(1)よりも強力な形式文法であるParsing Expression Grammar(以下PEG)によって構文解析を行う.PEGによる文法規則には曖昧さがなく,プログラミング言語の構文の記述やその処理系の作成に際し非常に有用である.既存のPEGベースの構文解析器では直接文字列を入力として受け付けるが,字句解析と構文解析を分けたい場合にそのままでは使用に適さない.たとえば,字句ベースのマクロ処理系であるCプリプロセッサを実装する際,マクロ展開後のコードに再度マクロ展開の処理が行われうる.その結果,マクロ展開の過程で同じレクシムに対して字句解析を複数回実行する場合がある.これを避けるためにPEGベースの構文解析器を使用しないとすると,字句解析や構文解析用にPEG以外の形式文法を学んだりその処理系を導入したりする必要がある.そこで文字列だけでなく字句列などを入力できるパックラットパーサーコンビネータをC++で実装し,本発表では実装の詳細について報告する.この実装を用いて生成した構文解析器はchar型だけでなく任意の型を返す前方反復子(Forward Iterator)を入力として受け付ける.結果はtuple・variant・optional・expectedなどを組み合わせたデータ構造として得られ,意味規則によって自由に変換することが可能である., Packrat parsing is based on Parsing Expression Grammar (PEG), which is more expressive than LALR(1) and is not ambiguous. So it is useful on describing the syntax of a programming language and implementing the language. However, it is not suitable to use PEG-based parser generators when we separately implement lexical analysis and syntax analysis, since existing PEG-based parsers receive only a string. For example, since a C preprocessor, which is a token-based macro processor, may expand a code fragment that is obtained by expanding macros, a lexer may process same lexemes more than once in macro expansion. When we do not use PEG-based parser for avoiding unnecessary lexical analysis, we need to study and use another lexer and parser. In this presentation we report a packrat parser combinator, implemented in C++, that receives not only strings but also sequences of tokens. The parser described by the combinator can receive as its input a Forward Iterator that returns not only characters but also values of any type. The output of the parser is obtained as a data structure that consists of tuples, variants, optionals and expecteds. We can process the result by describing semantic actions.},
 pages = {1--1},
 title = {マクロ処理の実装に適したパックラットパーサーコンビネータの設計と実装},
 volume = {10},
 year = {2017}
}