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

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

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
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
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement