• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

JakeWheat/intro_to_parsing: Introduction to parsing with Haskell and Parsec

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

JakeWheat/intro_to_parsing

开源软件地址(OpenSource Url):

https://github.com/JakeWheat/intro_to_parsing

开源编程语言(OpenSource Language):

Haskell 97.9%

开源软件介绍(OpenSource Introduction):

Intro to Parsing with Parsec in Haskell

Overview

WIP, a tutorial which demonstrates the basics of Parsec and goes on to build a SQL query parser.

You can view this tutorial as HTML online here:

and you can view the files directly in the github repository here:

Summary of sections

Introduction to parsing with Parsec, including a review of Text.Parsec.Char functions.

Creating a very simple expression language parser, and introducing some functions from Text.Parsec.Combinator.

Rewriting the simple expression parser code in a more succinct style.

Review and examples of all functions from Text.Parsec.Combinator, and some from Control.Applicative and Control.Monad.

The utility functions used in the previous tutorials, plus some notes on types in Parsec.

This covers using the Text.Parsec.Expr for expression parsing with prefix, postfix and infix operators with fixity.

Looks at an issue we have with the way the symbol parser in the Text.Parsec.Expr tutorial was used, and some possible fixes.

This covers the Text.Parsec.Perm module which is used for parsing different things in flexible order.

This covers Text.Parsec.Token which can be used to create token parsers easily.

This covers building a parser a subset of value expressions from SQL, which are an extension of the simple expression types and parsers covered in previous tutorials.

This covers building a parser to parse query expressions with select lists, simple from, where, group by, having and order by.

This extend the parser for query expressions to support a from clause with much more features including joins.

Here is the code from ValueExpressions, QueryExpressions and FromClause plus tests put together and rearranged as a coherent standalone module.

This quick module covers a simple pretty printer for our SQL ast.

In this document, we will explore error messages with parsec and how restructuring parser code can lead to better or worse error messages.

Going further

If you are interested in SQL parsing, check out the project to build a complete SQL parser here: http://jakewheat.github.io/simple-sql-parser/latest. The parsing code in the simple-sql-parser project is based on this tutorial code.

Extras

an executable which contains the boilerplate to run a parsec parser on a string passed as an argument

an executable which contains the boilerplate to run a parsec parser on a file passed as an argument

License: BSD3




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
ekmett/comonad: Haskell 98 comonads发布时间:2022-06-22
下一篇:
kazu-yamamoto/dns: DNS libary in Haskell发布时间:2022-06-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap