Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.compilers Subject: Re: specifying semantics, was Formatting of Language LRMs Date: Wed, 02 Jul 2014 09:51:51 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 50 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-07-003@comp.compilers> References: <14-06-010@comp.compilers> <14-06-023@comp.compilers> <14-06-025@comp.compilers> <14-06-027@comp.compilers> <14-06-030@comp.compilers> <14-06-031@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: miucha.iecc.com 1404356889 27492 2001:470:1f07:1126:0:676f:7373:6970 (3 Jul 2014 03:08:09 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Thu, 3 Jul 2014 03:08:09 +0000 (UTC) Keywords: semantics Posted-Date: 02 Jul 2014 23:08:09 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1293 Ivan Godard writes: >Well, conventionally the type system of a language is considered >semantics, yet the whole Algol68 type system, including checking all >expressions for type validity, is present in the VWG. What is conventionally called "syntax" is an artifact of the compiler technology (or maybe of specification technology, see below): Parsers are based on context-free grammars, and anything that is not groked by the parser is a syntax error, and what the parser accepts is considered the syntax; and everything else is called the semantics. And programming language specifications also follow that division: most of them provide a context-free grammar, and provide everything else in natural language. However, "everything else" is a very wide category, and if you look closer, you make further distinctions: There is static stuff and run-time stuff; typically name lookups are done statically (you get an error even if the code is not executed). One may consider the static stuff "syntax", but I think a more usual term is "static semantics". I think the vW stuff in Algol 68 is also static stuff. There is also the run-time semantics. There have been some ways to specify static stuff. vW grammars have not caught on; attribute grammars are more successful, but for compiler writers, not for language specifications; and even in compilers attribute grammars are not very widely used. It's mostly just code in the compiler implementation language. For the dynamic stuff, there has been quite a bit of academic work (operational semantics, denotational semantics (although I think they make little difference between static and dynamic stuff), but few uses in language specifications or compilers. I think Modula-3 used a formal specification, but don't know about the type. Generally, the problem of formal specifications is that, while they may be precise, doing a complete formal specification is hard and they are hard to understand (so it's easy to miss specification bugs). Doing partial formal specifications for areas that are easier to formally specify, and where the specifications are relatively easy to understand has been much more successful (context-free grammars are to most obvious example). And the rest is filled in with natural language. - anton -- M. Anton Ertl anton@mips.complang.tuwien.ac.at http://www.complang.tuwien.ac.at/anton/