开发者

Vhdl parser on C#

开发者 https://www.devze.com 2023-03-30 10:33 出处:网络
I need to make a vhdl parser. I decided to use the antlr parser generator and the vhdl grammar from their website http://www.antlr.org/grammar/1202750770887/vhdl.g.

I need to make a vhdl parser. I decided to use the antlr parser generator and the vhdl grammar from their website http://www.antlr.org/grammar/1202750770887/vhdl.g. I am having problems when checking the grammar and have this error:

The following token definitions can never be matched because prior tokens match the same input: LETTER,INTEGER,DIGIT...

If anyone has worked with this before, please tell me if the grammar is inco开发者_如何转开发rrect or if I'm doing something else incorrectly.


From vhdl.g

BASIC_IDENTIFIER
   :   LETTER ( '_' | LETTER | DIGIT )*
   ;

...

LETTER  
  :  'a'..'z' | 'A'..'Z'
  ;

LETTER, INTEGER and DIGIT all look like they should be a fragment, as they are never called by parser rules.

fragment LETTER 
  :  'a'..'z' | 'A'..'Z'
  ;

EDIT: As Bart has stated, since BASIC_IDENTIFIER is listed before LETTER in the grammar and covers all the cases LETTER does, the lexer will never create any LETTER tokens. This is what is causing the warnings.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号