nodejs / llparse

Generating parsers in LLVM IR
http://llparse.org
Other
584 stars 30 forks source link

Support conflicting select/match #28

Closed indutny closed 4 years ago

indutny commented 5 years ago

It should be possible to generate code for:

node
  .match('undef', ...)
  .match('undefined', ...);

The compiler could turn it into a tree of match+peek.

drom commented 4 years ago

Yes, that would be very useful.

knopp commented 4 years ago

This would be very helpful indeed. We're currently using modified http_parse and I'd like to switch to llhttp. We need to add RTSP support, which brings additional methods, one of which is GET_PARAMETER, which conflicts with GET. Our workaround right now is to append space to METHOD_MAP keys and then skip immediately to req_spaces_before_url (ignoring req_first_space_before_url).

It's not the end of the world, but having this working out of box would be much nicer :)

knopp commented 4 years ago

Just in case it helps someone, this commit in my fork adds RSTP support to llhttp. While having to append space to remove conflict is less than ideal, it's still lot cleaner than adding RTSP to original http-parser :)

indutny commented 4 years ago

I've just published a new version of llparse that supports this. Could you give it a try?

knopp commented 4 years ago

Thanks! I gave it a go, unfortunately it doesn't seem to work for me. You can see my branch here. It builds the parser but tests fail.

I might be doing something wrong, but I have both GET and GET_PARAMETER methods defined, all tests fail with method=0 instead of expected method=1. If I remove GET_PARAMETER method from the list tests pass.

indutny commented 4 years ago

Gosh, values... Sorry!

indutny commented 4 years ago

Alright. Should be really fixed now. Please give it another try!

knopp commented 4 years ago

Seems to be working! Tests passed and I did some testing with built parser which also works. Thanks!

indutny commented 4 years ago

Yay! Glad to help!