Igalia / pflua

Packet filtering in Lua
Other
313 stars 39 forks source link

Illegal keyword has confusing error message #153

Closed lukego closed 9 years ago

lukego commented 9 years ago

The error message for illegal keywords could be mistaken for a compiler NYI instead of a user error:

    $ rlwrap sudo ./snabb snsh -i
    Snabb> =require("pf").compile_filter("ip and tcp and garbage")
    Error in ../deps/pflua/src/pf/parse.lua:289: 
    Error: In expression "ip and tcp and garbage"
                                                ^
    keyword elision not implemented garbage
wingo commented 9 years ago

Tx for the report. @kbara, would you mind having a look once you've finished that makefile patch? Thanks :)

kbara commented 9 years ago

Gladly, @andywingo . I was bothered by that too when looking into https://github.com/Igalia/pflua/issues/137 and https://github.com/Igalia/pflua/pull/138 ; Luke's absolutely right that it should be improved.

kbara commented 9 years ago

@lukego It's been addressed now: % ./pflua-compile "ip and tcp and garbage" luajit: ../src/pf/parse.lua:289: Pflua parse error: In expression "ip and tcp and garbage" ^ garbage is not a recognized keyword. Likely causes: a) garbage is a typo, invalid keyword, or similar error. b) You're trying to implicitly repeat the previous clause's keyword. Instead of libpcap-style elision, explicitly use keywords in each clause: ie, "host a and host b", not "host a and b".

This was previously partly-explained by a comment, but not the error message: -- At this point the official pcap grammar is squirrely. It says: -- "If an identifier is given without a keyword, the most recent -- keyword is assumed. For example, not host vs and ace' is -- short fornot host vs and host aceand which should not be -- confused withnot (host vs or ace)`." For now we punt on this -- part of the grammar.

Are you happy with the clarity of the current message? If you are, I'll close this. (I'm also taking a look at how involved implementing keyword elision would be; that would allow this message to be greatly simplified).

kbara commented 9 years ago

I'll close this now; please re-open it or file a new bug if you have further related problems. :)