Show HN: A parser for electronic component descriptions
github.com
github.com
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...
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?
Right now it looks like only common/standard parts are parseable (resistors, leds, etc).
We are planning to include standard part naming schemes such as Pro Electron [1] and JEDEC [2] to recognize common diodes and transistors where it makes sense. The more interesting approach to me is to actually try recognize transistor descriptions such as "npn sot23 125mW beta=200 ic>=200mA". There is some work in progress, by dvc94ch, for both approaches (if I recall correctly) on the antlr branch: https://github.com/monostable/electro-grammar/pull/4
[1]: https://en.wikipedia.org/wiki/Pro_Electron [2]: https://en.wikipedia.org/wiki/JEDEC
I very strongly disagree.
Or just use Prolog.
(I'm not joking. I've been messing with parsers and such in Prolog the past week or so and I'm just blown away. I'm happy but also I feel stupid for not learning it sooner. I've wasted so much time and effort. I've been working too hard. Just learn Prolog and then use it, the total time saved will pay for the learning curve by the end of the year.)
Prolog is really interesting too but how would it work in practice for our use case?
You might take a look at the Meta-II metacompiler. It's really simple but by the same token it's trivial to port it to different languages. It's part of the basis for VPRI's PEG (Parser Expression Grammar) parser generators.