language-lua: Lua parser and pretty-printer

[ bsd3, language, library ] [ Propose Tags ]

Lua 5.3 lexer, parser and pretty-printer.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.3.0, 0.3.1, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.5.0, 0.6.0, 0.6.2, 0.6.2.1, 0.6.3, 0.6.3.1, 0.6.3.2, 0.7.0, 0.7.1, 0.8.0, 0.8.1, 0.9.0, 0.10.0, 0.11.0, 0.11.0.1 (info)
Change log CHANGELOG.md
Dependencies alex-tools (>=0.6 && <0.7), array (>=0.4 && <0.6), base (>=4.5 && <4.19), bytestring (>=0.10 && <0.12), deepseq, text (>=1.2 && <2.1) [details]
License BSD-3-Clause
Author Ömer Sinan Ağacan, Eric Mertens
Maintainer Eric Mertens <emertens@gmail.com>
Revised Revision 1 made by EricMertens at 2023-06-08T20:52:14Z
Category Language
Home page http://github.com/glguy/language-lua
Bug tracker http://github.com/glguy/language-lua/issues
Source repo head: git clone git://github.com/glguy/language-lua.git
Uploaded by EricMertens at 2019-08-29T16:32:08Z
Distributions LTSHaskell:0.11.0.1, NixOS:0.11.0.1
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 25935 total (70 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-08-29 [all 1 reports]

Readme for language-lua-0.11.0.1

[back to package description]

language-lua - Lua 5.3 lexer, parser and pretty-printer

Build Status Hackage

This package is just like any other language x packages. It provides lexer, parser and pretty-printer for Lua programming language.

Haddock documentation

Usage

This module provides 3 parsers.

  • chunk: Lua file parser.
  • exp: Lua expression parser.
  • stat: Lua statement parser.

Lexing is needed before running a parser. parseText function runs lexer before parsing. So if you want to parse a Lua expression, you can call parseText exp string, where string is the Lua expression to parse.

parseFile is a helper to parse Lua files. Example: parseFile "/path/to/lua/file". This is same as parseText chunk `fmap` readFile path.

Note that parseText may result with failure, so it's return type is Either ParserError a.

Lexer

Lexer is not exported by top-level Language.Lua module. You need to import Language.Lua.Lexer. After that, llex string scans the string and returns token list. Tokens are defined in Language.Lua.Token.

Pretty-printer

Pretty-printer is still under development, and subject to lots of changes. It works, but lots of functionality will be added.

For now, you can use pprint syntax_tree to pretty-print a Lua syntax tree.