fattaholmanan / p4-vscode-extension

Apache License 2.0
13 stars 4 forks source link

"no viable alternative at input" error for #define with no value #10

Open ebiken opened 3 years ago

ebiken commented 3 years ago

In P4, there are cases some valiables are defined without value to be used just for decisions (e.g. #ifndef).

For example: https://github.com/p4lang/p4c/blob/master/p4include/core.p4#L19

#ifndef _CORE_P4_
#define _CORE_P4_

will cause error : no viable alternative at input '_CORE_P4_\n#define'P4 Extension

Is this intentional? If not, I think it would be better not to show error since this is a valid P4 syntax.

fattaholmanan commented 3 years ago

No, it's not intentional! The grammar has to be updated to cover various preprocessors.

ebiken commented 3 years ago

Thank you for quick comment. Unfortunately I have no experience in this area so would appreciate if you can fix it when you have time. (Or let me know some pointers I should read and I could study & try to fix it while expecting to take a few months)

sadmankiba commented 2 years ago

p4_directives

Hi, directives like #if and #endif are not recognized too. Probably will require similar grammar.