Hi. I've had this sequence generator in my head for about 4 or 5 months now. I've been working on a mini-PLM for work projects, and it seemed right to me to be able to spec part numbers using a fixed grammar. The idea is that a part number would be stored in a DB along side its grammar specification. Then, when a part is queried, business logic can ingest the part number spec and parse the part number according to the spec. For companies where information about a part, its attributes, etc. are stored in a part number (category, revision, configuration codes, etc.) having this extra little tool could prove to be useful. At least I hope so.
I hacked together a python implementation, and then used v0 to mock a user interface. There is no backing DB, but there is the ability to import/export. If anyone is interested, I can put the app in a git repo and share it around.
---
A sequence is any list of characters that can be yielded in turn. This is distinct from a regex character class in that a sequence not only matches a set of characters, but it is also, given some input, the specification for which character comes next.
A sequence can be concatenated with another sequence, IE my_seq = Seq([1, 2, 3]) + Seq([a, b, c]). The second sequence is the lowest radix (like in base 10 numbers). If we say next(my_seq), we get 1a, then 1b, and so on.
In the linked app, there are two options that encapsulate this idea: "Range" and "Sequence".
A Literal is a sequence that returns the same one or more characters. We can use this as a separator: sep = Seq("-"). This will always return '-' on next().
A Select is a sequence that returns only the selected Literal.
An Alt is a sequence that bounces back and forth between two options. I'm not convinced this is necessary or even useful.
---
What's next: for this app, probably nothing. The sequence grammar needs to be refined. I'd like to use the 'combinator' approach to allow any sequence to be used in any other sequence. This would work both for parsing and for generating.
I hope you guys enjoy playing with this as much as I enjoyed "building" it. It was fun to watch this come together into something that 1) looks good, and 2) actually works pretty well.
all2•11h ago
I hacked together a python implementation, and then used v0 to mock a user interface. There is no backing DB, but there is the ability to import/export. If anyone is interested, I can put the app in a git repo and share it around.
---
A sequence is any list of characters that can be yielded in turn. This is distinct from a regex character class in that a sequence not only matches a set of characters, but it is also, given some input, the specification for which character comes next.
A sequence can be concatenated with another sequence, IE my_seq = Seq([1, 2, 3]) + Seq([a, b, c]). The second sequence is the lowest radix (like in base 10 numbers). If we say next(my_seq), we get 1a, then 1b, and so on.
In the linked app, there are two options that encapsulate this idea: "Range" and "Sequence".
A Literal is a sequence that returns the same one or more characters. We can use this as a separator: sep = Seq("-"). This will always return '-' on next().
A Select is a sequence that returns only the selected Literal.
An Alt is a sequence that bounces back and forth between two options. I'm not convinced this is necessary or even useful.
---
What's next: for this app, probably nothing. The sequence grammar needs to be refined. I'd like to use the 'combinator' approach to allow any sequence to be used in any other sequence. This would work both for parsing and for generating.
I hope you guys enjoy playing with this as much as I enjoyed "building" it. It was fun to watch this come together into something that 1) looks good, and 2) actually works pretty well.