LCSB-BioCore / PikaParser.jl

Pure Julia implementation of pika parser.
https://lcsb-biocore.github.io/PikaParser.jl
Apache License 2.0
52 stars 2 forks source link

[Feature request] Accept Regex expressions in `Scan` #21

Open mofeing opened 10 months ago

mofeing commented 10 months ago

Proposal

Often I find myself that some clauses are more easily parsed with a regex than with PikaParser clauses. The solution is to user a Scan in a way similar to:

rules = Dict(
    ...,
    :id => PikaParser.scan() do x
        matched = match(r"^[a-z][a-zA-Z0-9_]*", x)
        isnothing(matched) && return 0
        length(matched.match)
    end,
    ...,
)

It would be great if we could just pass the regex to scan.

Unsolved issues

Only regex of the form r"^..." should be accepted. If the ^ clause is not present, then the regex will search the pattern along all the input.

exaexa commented 10 months ago

notes for self when I get to this: