在C#VHDL语言解析器 [英] Vhdl parser on C#

查看:153
本文介绍了在C#VHDL语言解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做一个VHDL解析器。我决定用ANTLR解析器发电机和语法VHDL从他们的网站 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:

下面的标记定义决不能因为之前$匹配b $ b令牌匹配相同的输入:字母,INTEGER,数字...

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 incorrect or if I'm doing something else incorrectly.

推荐答案

从vhdl.g

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

...

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



LETTER,INTEGER,数字看起来都像他们应该是一个片段,因为他们永远不会被解析器称为规则。

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'
  ;



编辑:由于巴特曾表示,由于BASIC_IDENTIFIER在语法LETTER上市前,覆盖所有的情况下,信中,词法分析器将永远不会创建任何字母标记。这是什么原因造成的警告。

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.

这篇关于在C#VHDL语言解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆