Giter Club home page Giter Club logo

Comments (5)

erikd avatar erikd commented on June 1, 2024

Is this still an issue with the latest release?

from alex.

andreasabel avatar andreasabel commented on June 1, 2024

Yes.

$ alex Issue71.x 
alex: Prelude.head: empty list
$ alex --version
Alex version 3.2.4, (c) 2003 Chris Dornan and Simon Marlow

(2003 should be either dropped or updated.)

from alex.

andreasabel avatar andreasabel commented on June 1, 2024

The following call to head throws the error:
https://github.com/simonmar/alex/blob/f2c343b9b20ff9508f482e87528ef486c55b9f86/src/DFAMin.hs#L58

from alex.

andreasabel avatar andreasabel commented on June 1, 2024

The remaining problem is that if the lexer definition contains nullable tokens and the Alex gets stuck (on EOF or no just no possible DFA-transition), it outputs an infinite sequence of the nullable tokens. This happens because alex_scan_tkn gladly returns accepts of length 0.
The problem can be fixed by checking for the scanned length here:
https://github.com/simonmar/alex/blob/0198f7387a8f31fd8a7ff3efe453edbb00cba4fb/templates/GenericTemplate.hs#L155
and if the length is still 0, output AlexNone instead of accept or skip.

Why should a lexer not return tokens of length 0? Well, because the number of these token sequences is not determined, it could output any number of such tokens at any point. Thus, outputting 0 of such tokens only is a sensible (and the only sensible) choice.

from alex.

andreasabel avatar andreasabel commented on June 1, 2024

I'd say this issue is fixed now and can be closed.

from alex.

Related Issues (20)

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.