engineeringdept

engineeringdept

Enum/Stream pattern matching parser library?

I’ve got a list of text tokens + metadata as structs from a custom tokeniser. I want to match patterns in that list, some of which can be expressed with Elixir pattern matching, others of which will need a custom function to test for.

Some of the rules will need to be akin to simple regular expressions: not this, optional that, no more than three of these, etc.

Is there a library that will let me express a set of rules and match against those?

I found ExSpirit from @OvermindDL1, but I couldn’t see any examples of it being used for list patterns, just text. It looks like NimbleParsec just operates on text too. Should be I looking at something else? Thanks!

Most Liked

adw632

adw632

Doesn’t sound like you want a parser at all but some kind of constraint satisfier/solver. Perhaps you get some inspiration from these:

engineeringdept

engineeringdept

I think I probably just need to write my own combinator parser for this use case. I’m finding this video very helpful: https://www.youtube.com/watch?v=xNzoerDljjo

adw632

adw632

I do believe that @OvermindDL1 did say ExSpirit can work on non string based streams so you may be able to make it work with structured data.

I can’t really comment on feasibility other than what he wrote here:

Strangely enough that was in response to a comment by Sasha from the video you linked, as he used the slower combine parser which wasn’t a significant factor for his use case.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

Other popular topics Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
RisingFromAshes
I've read in another post that it may be possible with a router helper - but I couldn't find an appropriate one, and tbh, I'm still just ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement