没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > tinyap |
tinyap
|
1 | 0 | 105 |
贡献者 | 讨论 | 代码提交 |
This is not yet another parser. Tinyap takes some text and an a grammar describing AST as inputs, and outputs another AST that describes the text contents, according to the provided grammar.
Basically, tinyap is a recursive descent parser with backup. Thus, it's able to recognize any LL language. When a parse is successful, tinyap outputs an Abstract Syntax Tree (AST) that represents the input text in a structured manner.
Unlike most parsers, its code isn't factory-calibrated for a particular grammar. Instead, the grammar is data. Tinyap uses an AST that represents a grammar to parse its input text. This grammar AST is structured according to tinyap's grammar description language.
This parser is meant to allow quick and easy development of new languages and the corresponding interpreters or compilers, by defining a single tool and library to parse the source grammar as well as the source text according to the source grammar and walk the resulting ASTs.
The factory default for the grammar AST is the grammar description language itself. So one can parse a grammar description and directly use the parse output to parse some other text written in the described language. Tinyap also features a plugin mechanism for grammars, which allows for dynamic modular grammars. The ASTs tinyap produces can be serialized to and deserialized from buffers and files.
Finally, tinyap provides an interface to walk down the ASTs and makes it easy to write external plugins to visit the nodes, e.g. a compiler, an interpreter, a static evaluator, a renderer...
You can have a look at an extensive use of tinyap at http://code.google.com/p/tinyaml where tinyap is used to parse compile and extend a base meta-language.
A tutorial is available here : http://beublo23.free.fr/doxygen/tinyap/Tutorial.html
Until further request, C++ and Java API are more or less discontinued.
Contact me at damien dot leroux at gmail dot com for feedback, suggestions, requests or to help improving the code.