在我的项目中,我编写了一种用于处理键值对的语言。所以我有一些规则来匹配多个键keysList和一个值valuesList。现在我想在另一个规则中使用它们operationExpression : keysList CompareOperator valuesList ;哪个工作正常。我认为这将是很好命名这些规则元素keys和valuesoperationExpression : keys=keysList CompareOperator values=valueList ;当我现在尝试编译我的项目时,我收到一千个错误,抱怨缺少分号。当我查看生成的代码时,我发现 Antlr 给这些上下文起了奇怪的名字。我期望它们是keys,values但它们似乎是每个 C# 关键字(并且值之间有一些 @s)。public KeysListContext structexterndoushortfloatwhileoperatorrefprotectedreadonlycontinueelsecheckedlockcatchifcasenewusingstaticvoidinsizeofbytedoublesealedfinallythisuncheckedisparamsenumexplicitasnulltruefixedtrydecimalobjectimplicitinternalprivatevirtualboolconststringforinterfaceunsafelongoutswitchdelegateforeachdefaultulonggotopublicstackallocoverrideeventclasstypeofbreakfalsevolatileabstractuintintthrowcharnamespacesbyteshortreturnbase;public ValuesListContext @struct@extern@do@ushort@float@while@operator@ref@protected@readonly@continue@else@checked@lock@catch@if@case@new@using@static@void@in@sizeof@byte@double@sealed@finally@this@unchecked@is@params@enum@explicit@as@null@true@fixed@try@decimal@object@implicit@internal@private@virtual@bool@const@string@for@interface@unsafe@long@out@switch@delegate@foreachkey@ulong@goto@public@stackalloc@override@event@class@typeof@break@false@volatile@abstract@uint@int@throw@char@namespace@sbyte@short@return@base;每个其他名字似乎都很好。为什么 Antlr 这样做,为什么我不允许使用keys和values作为规则元素标签?
- 2 回答
- 0 关注
- 192 浏览
添加回答
举报
0/150
提交
取消