简体   繁体   English

是否存在类似于BNF的元语言,可以简明地描述自描述数据?

[英]Is there a metalanguage, similar to BNF that can concisely describe self-describing data?

Say for instance I had a data set that was self describing. 比方说,我有一个自我描述的数据集。 The first few well-structured records define data type IDs, which include the name and length of records, followed by content records, which start with the data IDs and contain a variable amount of data, depending on the ID. 前几个结构良好的记录定义数据类型ID,其中包括记录的名称和长度,后跟内容记录,内容记录以数据ID开头并包含可变数量的数据,具体取决于ID。

It would be easy enough to describe the definition records using BNF, EBNF, or ABNF .. but how would one concisely describe the content records, whose length is defined in the definition records? 使用BNF,EBNF或ABNF来描述定义记录是很容易的。但是如何简洁地描述内容记录,其长度在定义记录中定义?

Here is an example of describing the classic NetCDF data format with a BNF-like notation, but not concisely because the lengths of the data recs is not specified as a function of data in the the earlier dim and var definitions. 下面是一个使用类似BNF的符号描述经典NetCDF数据格式的示例 ,但不简洁,因为data recs的长度未指定为早期dimvar定义中的数据函数。

Are you asking how to define the content of the content records? 您是否在询问如何定义内容记录的内容? You made it clear that they're already defined in terms of the amount of data. 您已明确表示已根据数据量对其进行了定义。 If each data type ID implies not only a data length but also a data structure, it's straightforward, even in BNF, with one set of productions for each data type ID. 如果每个数据类型ID不仅意味着数据长度而且意味着数据结构,即使在BNF中,它也很简单,每个数据类型ID都有一组产生。 Is that what you mean? 你是这个意思吗? (It's even likely to be LR(1).) (它甚至可能是LR(1)。)

I am the creator of an Expert System, named XTRAN, that manipulates over 30 computer languages, as well as data and text. 我是名为XTRAN的专家系统的创建者,它操纵30多种计算机语言,以及数据和文本。 I got tired of writing parsers, so I created a parsing engine that executes EBNF at parse time, and I feed it the EBNF via the Expert System's rules language. 我厌倦了编写解析器,所以我创建了一个在解析时执行EBNF的解析引擎,我通过专家系统的规则语言将它提供给EBNF。 Since EBNF itself is meta, the schema I use to parse and store it for execution at parse time is meta-meta. 由于EBNF本身是元,我用来解析和存储它以便在解析时执行的模式是元元数据。

XTRAN's rules language also provides a data base capability in which a data base is in-memory, content-addressable, and stored as a sparse matrix. XTRAN的规则语言还提供数据库功能,其中数据库在内存中,内容可寻址,并存储为稀疏矩阵。 It's effectively an n-space, with each cell addressed via a list of subscripts, with each subscript being either elided, an integer, or a text string. 它实际上是一个n空间,每个单元通过下标列表寻址,每个下标都是省略的,整数或文本字符串。 So I can construct the scenario you describe quickly, by storing the data descriptions in the same data base that contains the content records. 因此,我可以通过将数据描述存储在包含内容记录的同一数据库中来快速构建您描述的场景。 It's loosely analogous to a relational data base describing its schema via its own contents. 它与通过其自身内容描述其模式的关系数据库非常类似。

FWIW, we call XTRAN's rules language meta-code, because it's a language that can manipulate other languages (as well as itself). FWIW,我们称之为XTRAN的规则语言元代码,因为它是一种可以操纵其他语言(以及它自身)的语言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM