GithubHelp home page GithubHelp logo

input-parsers's Introduction

input-parsers

An extension of the parsers library

The parsers library provides a number of subclasses of the Alternative type class, as well as lots of combinators useful for writing actual parsers.

What those classes like Parsing and CharParsing lack is the ability to express certain efficient parser primitives like Attoparsec's takeWhile. To rectify for this failing and enable more efficient parsers to be expressed, the present package input-parsers adds type classes InputParsing and InputCharParsing. The common characteristic of almost all their methods is that their parse result has the same type as the parser input, and is a prefix of the input.

The present package also exports the class DeterministicParsing, which provides a number of parser methods that are guaranteed to succeed with a single (typically longest possible) result. This is most useful for writing the lexical layer of a parser, but it can help avoid ambiguities and inefficiencies in general.

Finally, the package provides the class Position to abstract over the position the parser reached in the input stream.

input-parsers's People

Contributors

blamario avatar fiadliel avatar

Stargazers

 avatar

Watchers

 avatar  avatar

input-parsers's Issues

Doesn't build with attoparsec 0.14.2

We probably need a more strict bound here?

[4 of 5] Compiling Text.Parser.Input ( src/Text/Parser/Input.hs, dist/build/Text/Parser/Input.dyn_o )

src/Text/Parser/Input.hs:400:10: error:
    • No instance for (LookAheadParsing Attoparsec.Char8.Parser)
        arising from the superclasses of an instance declaration
    • In the instance declaration for
        ‘InputParsing Attoparsec.Char8.Parser’
    |
400 | instance InputParsing Attoparsec.Parser where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Text/Parser/Input.hs:402:15: error:
                         (Data.Attoparsec.Internal.Types.Parser ByteString))
        arising from a use of ‘lookAhead’
    • In the expression: lookAhead Attoparsec.Char8.takeByteString
      In an equation for ‘getInput’:
          getInput = lookAhead Attoparsec.Char8.takeByteString
      In the instance declaration for
        ‘InputParsing Attoparsec.Char8.Parser’
    |
402 |    getInput = lookAhead Attoparsec.takeByteString
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Text/Parser/Input.hs:412:10: error:
    • No instance for (CharParsing Attoparsec.Char8.Parser)
        arising from the superclasses of an instance declaration
    • In the instance declaration for
        ‘InputCharParsing Attoparsec.Char8.Parser’
    |
412 | instance InputCharParsing Attoparsec.Parser where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...

Build fails with binary dependency but without attoparsec

In src/Text/Parser/Input.hs:
The imports of Lazy and ByteString are guarded by an #ifdef MIN_VERSION_attoparsec. Later on (from line 460 on), a part of the code guarded by #ifdef MIN_VERSION_binary also makes use of these imports.

Example errors:

src/Text/Parser/Input.hs:462:41: error:
    Not in scope: type constructor or class ‘Lazy.ByteString’
    Neither ‘Control.Monad.Trans.RWS.Lazy’,
            ‘Control.Monad.Trans.State.Lazy’ nor ‘Control.Monad.Trans.Writer.Lazy’ exports ‘ByteString’.
    |
462 |    type ParserInput (Lazy Binary.Get) = Lazy.ByteString
    |                                         ^^^^^^^^^^^^^^^

src/Text/Parser/Input.hs:470:43: error:
    Not in scope: type constructor or class ‘ByteString’
    |
470 |    type ParserInput (Strict Binary.Get) = ByteString
    |                                           ^^^^^^^^^^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.