Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal keyword has confusing error message #153

Closed
lukego opened this issue Apr 14, 2015 · 4 comments
Closed

Illegal keyword has confusing error message #153

lukego opened this issue Apr 14, 2015 · 4 comments

Comments

@lukego
Copy link
Contributor

lukego commented Apr 14, 2015

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
Copy link
Contributor

wingo commented Apr 14, 2015

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

@kbara
Copy link
Contributor

kbara commented Apr 14, 2015

Gladly, @andywingo . I was bothered by that too when looking into #137 and #138 ; Luke's absolutely right that it should be improved.

kbara pushed a commit that referenced this issue Apr 14, 2015
As raised in #153
This change introduces a clearer and much more verbose error message on
similar invalid pflang input.
kbara pushed a commit that referenced this issue Apr 14, 2015
As raised in #153
This change introduces a clearer and much more verbose error message on
similar invalid pflang input.
@kbara
Copy link
Contributor

kbara commented Apr 14, 2015

@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
Copy link
Contributor

kbara commented Apr 16, 2015

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

@kbara kbara closed this as completed Apr 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants