转自steve的blog。
其实说得也很简单,转载以备忘。
更详细的可以去看Keith Short的这本书:Adapted from Models, Frameworks and Tools,网上有下载。
Recent postings have talked about “semantics” of graphical languages. When I was involved in UML development this word caused a lot of argument and confusion. In my view, it goes like this.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
A graphical language has three primary aspects: concrete syntax, abstract syntax, and semantics. Concrete syntax (notation) defines what the language actually looks like on the screen or the paper: the shapes, connections, adornments and textual annotations that the user sees and manipulates, and the gestures used to manipulate them. Abstract syntax (grammar) gives names to the concepts that the notation depicts, and defines which configurations of these are valid. Often, the abstract syntax for a graphical language is defined using a model, itself expressed using a graphical language. Some people call this a “metamodel”; my colleagues and I usually call it a domain model. Usually such a model is insufficient on its own, and must be supplemented by an additional set of constraints, sometimes called “well-formedness rules”. A typical such rule would be the constraint that an inheritance graph must not form cycles.
Semantics is none of the above, although terms such as “static semantics” or “short-range semantics” have been used to refer to what I called abstract syntax. Semantics define what valid expressions in the language mean. (Aside: saying “expressions in the language” is very easy when talking about textual languages, whereas thinking of a diagram as an expression may feel a little uncomfortable. You have to get used to it.) The way to give meaning to an expression is to map it to one or more other interesting structures whose meaning is known. To define semantics objectively, the mapping and the meaning of the result must both be precisely defined.
A mapping of the graphical language to statements in a natural language does not give objective semantics, although it may be useful. A precise mapping of the graphical language to a programming language gives objective semantics to the extent that the programming language does: which is high, in the case of popular standardized languages. If such a mapping exists it probably means that the diagram is a visualization of some aspect of the structure of the program. Another useful target for semantic mappings is expressions in some logical formalism, such as set theory, predicate logic or abstract algebra. Examples of diagrams with this kind of semantics are Venn diagrams and Petri nets. A final useful target for semantic mappings is another graphical language, which itself has well-defined semantics.
You might observe that abstract syntax involves a mapping from expressions in the language to the structure {valid, invalid}, and therefore is a kind of degenerate semantics. I prefer to distinguish validity from meaning. You might also observe that it might be desirable to give some kind of meaning to invalid expressions. To do that, you’d have to introduce different kinds of validity.
分享到:
相关推荐
编译原理语法分析语义分析 语法分析(Syntax analysis或Parsing)和语法分析程序(Parser) 语法分析是编译过程的一个逻辑阶段。语法分析的任务是在词法分析的基础上将单词序列组合成各类语法短语,如“程序”,...
以计算器危机春,实现编译原理中的词法、语法、语义分析,编写成的词法、语法、语义分析器,用vs2010编写
这是经过查找资料之后总结的关于自然语言理解中的语法学、语义学和语用学的内容!共同进步!
vscode中的语法高亮和语义高亮 Vscode Syntax Highlight Vscode Semantic Highlight
用java语言编写的词法分析器、语法分析器和语义分析器,已经内置了静态的基本语言,通过文件读入代码,上传供各位学习交流使用。
用c语言实现的语法语义分析程序 实现了四元式得生成功能齐全
编译原理-词法,语法,语义
一本关于丘奇演算的教材,电子书,作者是荷兰学者H.P.巴伦德莱赫特
高级程序设计中涉及到的语义与语法的关系和构建。
介绍JSP的语法和语义
编译原理原理课程设计,源码加报告。这是我的课程设计,其中包括了语法语义分析
通过上机实习,加深对语法制导翻译原理的理解,掌握将语法分析所识别的语法成分变换为中间代码的语义翻译方法. 实验要求 采用递归下降语法制导翻译法,对算术表达式、赋值语句进行语义分析并生成四元式序列。 实验的...
这是我本科编译原理课上完成的实验(C语言编写),文件打包了从词法分析、语法分析到语义分析的代码,使用codeblock编写。
C++语法语义分析器 本程序在屏幕上输入待分析的C语言 赋值 语句 格式: begin(请一定输入,否则不能运行) s=...; a=...; b=...; end #(结束符号) 输出三地址指令: t1=... t2=... s=...
编译原理课程设计,内容包括词法分析、语法分析、语义分析
计算机编译原理实验——语义和语法分析实验代码。
Java语言子集语法、语义分析器 1.强化对系统软件综合工程实现能力、规划能力的训练; 2.增强对语法分析器、语义分析及代码生成器基本实现技术的理解; 3. 提高训练。
编译原理的课后附录实验,是源程序哦!运行好的!
λ-演算的语法和语义
编译原理词法分析,语法分析,语义分析(源代码和实验报告),已经测试运行,绝对对得起10分(本人的承诺)。