Skip to content

Please use FSM to analyze the docstring, do not use regular expression. #95

Closed as not planned

Description

@qkxie

I originally thought that you would use lexical analysis and syntactic analysis from the principles of compilation, and analyze docstring through a finite state machine. However, when I took a look at the source code, I found that you were actually using regular expressions. The use of regular expressions will lead to a significant reduction in flexibility.

Activity

  1. rr- commented on Jul 20, 2025

    @rr-
    Owner

    Creating a fully manual lexer and parser can be a tough task. While adding a library like parsimonious or lark could simplify things a lot, it would also add extra bulk to the package which I think should be avoided. That being said, I'm open to any pull requests if you'd like to explore different approaches.

  2. rr- commented on Nov 7, 2026

    @rr-
    Owner

    Thanks for the suggestion and for thinking about how the parser is built. Since this was opened, every style reads docstrings through one shared line lexer (#140), which is where the flexibility mattered most. The pieces inside a line, such as item heads and type marks, are still matched with small regexes. A fully hand-written or grammar-based parser would add a lot of code or a dependency without fixing any bug we know of, so I'm closing this. A case the regexes get wrong is welcome as a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions