
Show HN: A parser for electronic component descriptions - kasbah
https://github.com/monostable/electro-grammar
======
kasbah
Hey folks, I created this to augment the Octopart API while working on bill of
materials tools for [https://kitspace.org](https://kitspace.org).

Working with Nearley was a fun experience and I recommend the blog post that
got me started with it to anyone who is interested in writing a parser in JS:
[https://medium.com/@gajus/parsing-absolutely-anything-in-
jav...](https://medium.com/@gajus/parsing-absolutely-anything-in-javascript-
using-earley-algorithm-886edcc31e5e)

We have started porting it to Antlr to make it language agnostic though we are
still open to looking at other options as well. Does anyone have any good
experience or some ideas for alternative approaches?

~~~
elcritch
Antlr the last I looked and tried to use it was a pain. Version mismatches and
incompatible changes... Plain old bison/yacc/lex or some of the newer Rust
parsing libraries would probably be simpler and easier to maintain.

~~~
kasbah
Yeah dvc94ch who wrote most of what's been done for v2 so far was suggesting
Rust and then web-assembly. Kind of warming to it after using Antlr for a
while. We both really need JS versions though so I am still not sold.
Compiling with Emscripten might be an option but it could be a lot of pain as
well.

~~~
elcritch
I’ve just tinkered with wasm and rust, but it was surprisingly pretty
straightforward. It seems there a huge amount of effort being placed in the
ecosystem. Great project so far! I’ll have to check out the bom tools.

~~~
kasbah
But if I'd like to support older browsers I am out of luck, no?

~~~
striking
Emscripten compiles to asm.js, which is just a subset of JS. CanIUse will tell
you some browsers don't support it, but it really means they don't support
accelerating it. Your code very well may still run in those browsers (but I'm
not sure about the determinant of those cases).

------
gravypod
Is there a formatter planned for formatting an object into a pretty printed
string?

~~~
kasbah
I have thought about it since it should be pretty easy to do. Feel free to
open an issue or make a PR.

