EBNF标识符定义 [英] EBNF Definition of Identifier
问题描述
标识符的EBNF定义为(a-zA-Z, _ ){a-zA-Z0-9, _ }
.有人可以解释这个定义,并根据这个定义给我一个有效的标识符.
The EBNF definition of an identifier is (a-zA-Z, _ ){a-zA-Z0-9, _ }
. Can someone explain this definition and give me a valid identifier by this definition.
推荐答案
EBNF 之类的语言相差很大. 通常,我将定义如下内容:
The syntax of EBNF like languages differ a lot. Normally I would define something like this:
letter = "a" | "b" | ... | "z" | "A" | ... | "Z";
digit = "0" | "1" | "2" | ... | "9";
identifier = letter , { letter | digit | "_" } ;
您的表单看起来像 EBNF 和 regex . 如果我不知道我们在说哪种语言,很难说这意味着什么.
Your form looks like a mixture of EBNF and regex. It is hard to tell what this means if I don't know which language we are talking about.
但是,仅凭猜测,我会说它描述的是类似于C的标识符(例如变量名),例如"myVar_0123ab". 标识符必须以字母或下划线"_"开头,后跟字母,下划线和数字.
But by pure guessing, I would say it describes a C-like identifier (e.g. variable name) like "myVar_0123ab". The identifier has to start with a letter, or an underline '_', followed by letters, underlines and digits.
这篇关于EBNF标识符定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!