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

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
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
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
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
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

Other popular topics Top

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
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement